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:
@@ -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);
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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",
|
||||
)),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user