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:
@@ -127,7 +127,7 @@ impl ModulusPoly {
|
||||
pub fn add(&self, other: Rc<ModulusPoly>) -> Result<Rc<ModulusPoly>, Exceptions> {
|
||||
if self.field != other.field {
|
||||
return Err(Exceptions::illegalArgument(
|
||||
"ModulusPolys do not have same ModulusGF field".to_owned(),
|
||||
"ModulusPolys do not have same ModulusGF field",
|
||||
));
|
||||
}
|
||||
if self.isZero() {
|
||||
@@ -161,7 +161,7 @@ impl ModulusPoly {
|
||||
pub fn subtract(&self, other: Rc<ModulusPoly>) -> Result<Rc<ModulusPoly>, Exceptions> {
|
||||
if self.field != other.field {
|
||||
return Err(Exceptions::illegalArgument(
|
||||
"ModulusPolys do not have same ModulusGF field".to_owned(),
|
||||
"ModulusPolys do not have same ModulusGF field",
|
||||
));
|
||||
}
|
||||
if other.isZero() {
|
||||
@@ -173,7 +173,7 @@ impl ModulusPoly {
|
||||
pub fn multiply(&self, other: Rc<ModulusPoly>) -> Result<Rc<ModulusPoly>, Exceptions> {
|
||||
if !(self.field == other.field) {
|
||||
return Err(Exceptions::illegalArgument(
|
||||
"ModulusPolys do not have same ModulusGF field".to_owned(),
|
||||
"ModulusPolys do not have same ModulusGF field",
|
||||
));
|
||||
}
|
||||
if self.isZero() || other.isZero() {
|
||||
|
||||
@@ -315,9 +315,7 @@ impl PDF417 {
|
||||
}
|
||||
}
|
||||
|
||||
dimension.ok_or(Exceptions::writer(
|
||||
"Unable to fit message in columns".to_owned(),
|
||||
))
|
||||
dimension.ok_or(Exceptions::writer("Unable to fit message in columns"))
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -120,7 +120,7 @@ static EC_COEFFICIENTS: Lazy<[Vec<u32>; 9]> = Lazy::new(|| {
|
||||
pub fn getErrorCorrectionCodewordCount(errorCorrectionLevel: u32) -> Result<u32, Exceptions> {
|
||||
if errorCorrectionLevel > 8 {
|
||||
return Err(Exceptions::illegalArgument(
|
||||
"Error correction level must be between 0 and 8!".to_owned(),
|
||||
"Error correction level must be between 0 and 8!",
|
||||
));
|
||||
}
|
||||
Ok(1 << (errorCorrectionLevel + 1))
|
||||
@@ -135,7 +135,7 @@ pub fn getErrorCorrectionCodewordCount(errorCorrectionLevel: u32) -> Result<u32,
|
||||
*/
|
||||
pub fn getRecommendedMinimumErrorCorrectionLevel(n: u32) -> Result<u32, Exceptions> {
|
||||
if n == 0 {
|
||||
Err(Exceptions::illegalArgument("n must be > 0".to_owned()))
|
||||
Err(Exceptions::illegalArgument("n must be > 0"))
|
||||
} else if n <= 40 {
|
||||
Ok(2)
|
||||
} else if n <= 160 {
|
||||
@@ -145,7 +145,7 @@ pub fn getRecommendedMinimumErrorCorrectionLevel(n: u32) -> Result<u32, Exceptio
|
||||
} else if n <= 863 {
|
||||
Ok(5)
|
||||
} else {
|
||||
Err(Exceptions::writer("No recommendation possible".to_owned()))
|
||||
Err(Exceptions::writer("No recommendation possible"))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -179,7 +179,7 @@ pub fn encodeHighLevel(
|
||||
) -> Result<String, Exceptions> {
|
||||
let mut encoding = encoding;
|
||||
if msg.is_empty() {
|
||||
return Err(Exceptions::writer("Empty message not allowed".to_owned()));
|
||||
return Err(Exceptions::writer("Empty message not allowed"));
|
||||
}
|
||||
|
||||
if encoding.is_none() && !autoECI {
|
||||
@@ -797,9 +797,7 @@ fn determineConsecutiveBinaryCount<T: ECIInput + ?Sized + 'static>(
|
||||
|
||||
if !can_encode {
|
||||
if TypeId::of::<T>() != TypeId::of::<NoECIInput>() {
|
||||
return Err(Exceptions::illegalState(
|
||||
"expected NoECIInput type".to_owned(),
|
||||
));
|
||||
return Err(Exceptions::illegalState("expected NoECIInput type"));
|
||||
}
|
||||
let ch = input.charAt(idx)?;
|
||||
return Err(Exceptions::writer(format!(
|
||||
|
||||
Reference in New Issue
Block a user