remove .to_owned() calls on &str in exceptions

This commit is contained in:
Vukašin Stepanović
2023-02-15 11:03:27 +00:00
parent 722ce78fd0
commit 528ddea41c
47 changed files with 107 additions and 167 deletions

View File

@@ -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() {

View File

@@ -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"))
}
/**

View File

@@ -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"))
}
}

View File

@@ -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!(