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:
@@ -249,7 +249,7 @@ fn encodeFast(contents: &str, forcedCodeSet: i32) -> Result<Vec<bool>, Exception
|
||||
if position + 1 == length {
|
||||
// this is the last character, but the encoding is C, which always encodes two characers
|
||||
return Err(Exceptions::illegalArgument(
|
||||
"Bad number of characters for digit only encoding.".to_owned(),
|
||||
"Bad number of characters for digit only encoding.",
|
||||
));
|
||||
}
|
||||
let s: String = contents
|
||||
|
||||
@@ -45,9 +45,7 @@ impl OneDimensionalCodeWriter for EAN13Writer {
|
||||
}
|
||||
13 => {
|
||||
if !reader.checkStandardUPCEANChecksum(&contents)? {
|
||||
return Err(Exceptions::illegalArgument(
|
||||
"Contents do not pass checksum".to_owned(),
|
||||
));
|
||||
return Err(Exceptions::illegalArgument("Contents do not pass checksum"));
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
|
||||
@@ -55,9 +55,7 @@ impl OneDimensionalCodeWriter for EAN8Writer {
|
||||
}
|
||||
8 => {
|
||||
if !EAN8Reader.checkStandardUPCEANChecksum(&contents)? {
|
||||
return Err(Exceptions::illegalArgument(
|
||||
"Contents do not pass checksum".to_owned(),
|
||||
));
|
||||
return Err(Exceptions::illegalArgument("Contents do not pass checksum"));
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
|
||||
@@ -33,7 +33,7 @@ impl OneDimensionalCodeWriter for ITFWriter {
|
||||
let length = contents.chars().count();
|
||||
if length % 2 != 0 {
|
||||
return Err(Exceptions::illegalArgument(
|
||||
"The length of the input should be even".to_owned(),
|
||||
"The length of the input should be even",
|
||||
));
|
||||
}
|
||||
if length > 80 {
|
||||
|
||||
@@ -101,7 +101,7 @@ pub trait OneDimensionalCodeWriter: Writer {
|
||||
fn checkNumeric(contents: &str) -> Result<(), Exceptions> {
|
||||
if !NUMERIC.is_match(contents) {
|
||||
Err(Exceptions::illegalArgument(
|
||||
"Input should only contain digits 0-9".to_owned(),
|
||||
"Input should only contain digits 0-9",
|
||||
))
|
||||
} else {
|
||||
Ok(())
|
||||
@@ -163,9 +163,7 @@ impl Writer for L {
|
||||
hints: &crate::EncodingHintDictionary,
|
||||
) -> Result<crate::common::BitMatrix, crate::Exceptions> {
|
||||
if contents.is_empty() {
|
||||
return Err(Exceptions::illegalArgument(
|
||||
"Found empty contents".to_owned(),
|
||||
));
|
||||
return Err(Exceptions::illegalArgument("Found empty contents"));
|
||||
}
|
||||
|
||||
if width < 0 || height < 0 {
|
||||
|
||||
@@ -51,7 +51,7 @@ pub fn buildBitArrayFromString(data: &str) -> Result<BitArray, Exceptions> {
|
||||
if i % 9 == 0 {
|
||||
// spaces
|
||||
if dotsAndXs.chars().nth(i).ok_or(Exceptions::parseEmpty())? != ' ' {
|
||||
return Err(Exceptions::illegalState("space expected".to_owned()));
|
||||
return Err(Exceptions::illegalState("space expected"));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -55,9 +55,7 @@ impl OneDimensionalCodeWriter for UPCEWriter {
|
||||
&upc_e_reader::convertUPCEtoUPCA(&contents)
|
||||
.ok_or(Exceptions::illegalArgumentEmpty())?,
|
||||
)? {
|
||||
return Err(Exceptions::illegalArgument(
|
||||
"Contents do not pass checksum".to_owned(),
|
||||
));
|
||||
return Err(Exceptions::illegalArgument("Contents do not pass checksum"));
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
@@ -76,9 +74,7 @@ impl OneDimensionalCodeWriter for UPCEWriter {
|
||||
.to_digit(10)
|
||||
.ok_or(Exceptions::parseEmpty())? as usize; //Character.digit(contents.charAt(0), 10);
|
||||
if firstDigit != 0 && firstDigit != 1 {
|
||||
return Err(Exceptions::illegalArgument(
|
||||
"Number system must be 0 or 1".to_owned(),
|
||||
));
|
||||
return Err(Exceptions::illegalArgument("Number system must be 0 or 1"));
|
||||
}
|
||||
|
||||
let checkDigit = contents
|
||||
|
||||
Reference in New Issue
Block a user