mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 04:12:34 +00:00
remove .to_owned() calls on &str in exceptions
This commit is contained in:
@@ -121,17 +121,17 @@ impl AddressBookParsedRXingResult {
|
||||
) -> Result<Self, Exceptions> {
|
||||
if phone_numbers.len() != phone_types.len() && !phone_types.is_empty() {
|
||||
return Err(Exceptions::illegalArgument(
|
||||
"Phone numbers and types lengths differ".to_owned(),
|
||||
"Phone numbers and types lengths differ",
|
||||
));
|
||||
}
|
||||
if emails.len() != email_types.len() && !email_types.is_empty() {
|
||||
return Err(Exceptions::illegalArgument(
|
||||
"Emails and types lengths differ".to_owned(),
|
||||
"Emails and types lengths differ",
|
||||
));
|
||||
}
|
||||
if addresses.len() != address_types.len() && !address_types.is_empty() {
|
||||
return Err(Exceptions::illegalArgument(
|
||||
"Addresses and types lengths differ".to_owned(),
|
||||
"Addresses and types lengths differ",
|
||||
));
|
||||
}
|
||||
Ok(Self {
|
||||
|
||||
@@ -91,9 +91,7 @@ fn vin_char_value(c: char) -> Result<u32, Exceptions> {
|
||||
'J'..='R' => Ok((c as u8 as u32 - b'J' as u32) + 1),
|
||||
'S'..='Z' => Ok((c as u8 as u32 - b'S' as u32) + 2),
|
||||
'0'..='9' => Ok(c as u8 as u32 - b'0' as u32),
|
||||
_ => Err(Exceptions::illegalArgument(
|
||||
"vin char out of range".to_owned(),
|
||||
)),
|
||||
_ => Err(Exceptions::illegalArgument("vin char out of range")),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,7 +102,7 @@ fn vin_position_weight(position: usize) -> Result<usize, Exceptions> {
|
||||
9 => Ok(0),
|
||||
10..=17 => Ok(19 - position),
|
||||
_ => Err(Exceptions::illegalArgument(
|
||||
"vin position weight out of bounds".to_owned(),
|
||||
"vin position weight out of bounds",
|
||||
)),
|
||||
}
|
||||
}
|
||||
@@ -113,7 +111,7 @@ fn check_char(remainder: u8) -> Result<char, Exceptions> {
|
||||
match remainder {
|
||||
0..=9 => Ok((b'0' + remainder) as char),
|
||||
10 => Ok('X'),
|
||||
_ => Err(Exceptions::illegalArgument("remainder too high".to_owned())),
|
||||
_ => Err(Exceptions::illegalArgument("remainder too high")),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user