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

@@ -234,9 +234,7 @@ impl C40Encoder {
context.writeCodeword(C40_UNLATCH);
}
} else {
return Err(Exceptions::illegalState(
"Unexpected case. Please report!".to_owned(),
));
return Err(Exceptions::illegalState("Unexpected case. Please report!"));
}
context.signalEncoderChange(ASCII_ENCODATION);

View File

@@ -95,9 +95,7 @@ impl EdifactEncoder {
}
if count > 4 {
return Err(Exceptions::illegalState(
"Count must not exceed 4".to_owned(),
));
return Err(Exceptions::illegalState("Count must not exceed 4"));
}
let restChars = count - 1;
let encoded = Self::encodeToCodewords(buffer)?;
@@ -149,9 +147,7 @@ impl EdifactEncoder {
fn encodeToCodewords(sb: &str) -> Result<String, Exceptions> {
let len = sb.chars().count();
if len == 0 {
return Err(Exceptions::illegalState(
"StringBuilder must not be empty".to_owned(),
));
return Err(Exceptions::illegalState("StringBuilder must not be empty"));
}
let c1 = sb
.chars()

View File

@@ -67,7 +67,7 @@ impl<'a> EncoderContext<'_> {
})?
} else {
return Err(Exceptions::illegalArgument(
"Message contains characters outside ISO-8859-1 encoding.".to_owned(),
"Message contains characters outside ISO-8859-1 encoding.",
));
};
Ok(Self {

View File

@@ -155,7 +155,7 @@ const ALOG: [u32; 255] = {
pub fn encodeECC200(codewords: &str, symbolInfo: &SymbolInfo) -> Result<String, Exceptions> {
if codewords.chars().count() != symbolInfo.getDataCapacity() as usize {
return Err(Exceptions::illegalArgument(
"The number of codewords does not match the selected symbol".to_owned(),
"The number of codewords does not match the selected symbol",
));
}
let mut sb = String::with_capacity(

View File

@@ -129,7 +129,7 @@ impl SymbolInfo {
16 => Ok(4),
36 => Ok(6),
_ => Err(Exceptions::illegalState(
"Cannot handle this number of data regions".to_owned(),
"Cannot handle this number of data regions",
)),
}
}
@@ -141,7 +141,7 @@ impl SymbolInfo {
16 => Ok(4),
36 => Ok(6),
_ => Err(Exceptions::illegalState(
"Cannot handle this number of data regions".to_owned(),
"Cannot handle this number of data regions",
)),
}
}