cargo clippy --fix

This commit is contained in:
Henry Schimke
2023-01-27 15:24:24 -06:00
parent 58e6827e89
commit 42d40de755
86 changed files with 196 additions and 335 deletions

View File

@@ -37,7 +37,7 @@ impl OneDimensionalCodeWriter for CodaBarWriter {
fn encode_oned(&self, contents: &str) -> Result<Vec<bool>, crate::Exceptions> {
let contents = if contents.chars().count() < 2 {
// Can't have a start/end guard, so tentatively add default guards
format!("{}{}{}", DEFAULT_GUARD, contents, DEFAULT_GUARD)
format!("{DEFAULT_GUARD}{contents}{DEFAULT_GUARD}")
} else {
// Verify input and calculate decoded length.
let firstChar = contents.chars().next().unwrap().to_ascii_uppercase();
@@ -53,8 +53,7 @@ impl OneDimensionalCodeWriter for CodaBarWriter {
if startsNormal {
if !endsNormal {
return Err(Exceptions::IllegalArgumentException(Some(format!(
"Invalid start/end guards: {}",
contents
"Invalid start/end guards: {contents}"
))));
}
// else already has valid start/end
@@ -62,8 +61,7 @@ impl OneDimensionalCodeWriter for CodaBarWriter {
} else if startsAlt {
if !endsAlt {
return Err(Exceptions::IllegalArgumentException(Some(format!(
"Invalid start/end guards: {}",
contents
"Invalid start/end guards: {contents}"
))));
}
// else already has valid start/end
@@ -72,12 +70,11 @@ impl OneDimensionalCodeWriter for CodaBarWriter {
// Doesn't start with a guard
if endsNormal || endsAlt {
return Err(Exceptions::IllegalArgumentException(Some(format!(
"Invalid start/end guards: {}",
contents
"Invalid start/end guards: {contents}"
))));
}
// else doesn't end with guard either, so add a default
format!("{}{}{}", DEFAULT_GUARD, contents, DEFAULT_GUARD)
format!("{DEFAULT_GUARD}{contents}{DEFAULT_GUARD}")
}
};
@@ -95,8 +92,7 @@ impl OneDimensionalCodeWriter for CodaBarWriter {
resultLength += 10;
} else {
return Err(Exceptions::IllegalArgumentException(Some(format!(
"Cannot encode : '{}'",
ch
"Cannot encode : '{ch}'"
))));
}
}