Skip to content

Commit 7065a5e

Browse files
committed
clippy + fmt + microop
1 parent 3945d84 commit 7065a5e

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/icon.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ fn parse_dmi_line(
6868
) -> Result<(&str, String), DmiError> {
6969
let line_split = line.split_once(" = ");
7070
if line_split.is_none() {
71-
return Err(DmiError::BlockEntry(format!("No value was found for line: '{line}' (must contain ' = ')!")));
71+
return Err(DmiError::BlockEntry(format!(
72+
"No value was found for line: '{line}' (must contain ' = ')!"
73+
)));
7274
}
7375
let line_split = line_split.unwrap();
7476
// Now we need to parse after the equals
@@ -78,10 +80,11 @@ fn parse_dmi_line(
7880
// Flags
7981
let mut quoted = false;
8082
let mut escaped = false;
83+
let mut used_quotes = false;
8184

8285
let value_bytes = line_split.1.as_bytes();
83-
for char_idx in 0..num_chars {
84-
let char: char = value_bytes[char_idx] as char;
86+
for (char_idx, char) in value_bytes.iter().enumerate() {
87+
let char = *char as char;
8588
let escape_this_char = escaped;
8689
escaped = false;
8790
match char {
@@ -107,6 +110,7 @@ fn parse_dmi_line(
107110
return Err(DmiError::BlockEntry(format!("Line with value '{line}' starts quotes after the first character in its value. This is not allowed.")));
108111
}
109112
quoted = !quoted;
113+
used_quotes = true;
110114
continue;
111115
}
112116
}
@@ -117,11 +121,11 @@ fn parse_dmi_line(
117121
}
118122
_ => {}
119123
}
120-
if allow_quotes && require_quotes && !quoted {
121-
return Err(DmiError::Generic(format!("Line with value '{line}' is required to have quotes after the equals sign, but does not quote all its contents!")));
122-
}
123124
post_equals.push(char);
124125
}
126+
if allow_quotes && require_quotes && !used_quotes {
127+
return Err(DmiError::Generic(format!("Line with value '{line}' is required to have quotes after the equals sign, but does not wrap its contents in quotes!")));
128+
}
125129
Ok((line_split.0, post_equals))
126130
}
127131

0 commit comments

Comments
 (0)