Implement clippy suggestions

This commit is contained in:
Henry Schimke
2023-01-04 14:48:16 -06:00
parent c65eadf102
commit 48287631dd
196 changed files with 2465 additions and 2574 deletions

View File

@@ -25,28 +25,22 @@ use super::OneDimensionalCodeWriter;
*
* @author erik.barbara@gmail.com (Erik Barbara)
*/
#[derive(OneDWriter)]
#[derive(OneDWriter, Default)]
pub struct ITFWriter;
impl Default for ITFWriter {
fn default() -> Self {
Self {}
}
}
impl OneDimensionalCodeWriter for ITFWriter {
fn encode_oned(&self, contents: &str) -> Result<Vec<bool>, Exceptions> {
let length = contents.chars().count();
if length % 2 != 0 {
return Err(Exceptions::IllegalArgumentException(
return Err(Exceptions::IllegalArgumentException(Some(
"The length of the input should be even".to_owned(),
));
)));
}
if length > 80 {
return Err(Exceptions::IllegalArgumentException(format!(
return Err(Exceptions::IllegalArgumentException(Some(format!(
"Requested contents should be less than 80 digits long, but got {}",
length
)));
))));
}
Self::checkNumeric(contents)?;