From 528ddea41c9904082daae8c82196e110b792d1fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vuka=C5=A1in=20Stepanovi=C4=87?= Date: Wed, 15 Feb 2023 11:03:27 +0000 Subject: [PATCH] remove .to_owned() calls on &str in exceptions --- src/aztec/decoder.rs | 14 ++++------ src/aztec/detector.rs | 4 +-- src/aztec/encoder/aztec_encoder.rs | 6 ++--- src/aztec/encoder/high_level_encoder.rs | 4 +-- src/aztec/encoder/state.rs | 2 +- src/client/result/AddressBookParsedResult.rs | 6 ++--- src/client/result/VINResultParser.rs | 8 +++--- src/common/bit_array.rs | 4 +-- src/common/bit_matrix.rs | 18 +++++-------- src/common/character_set_eci.rs | 2 +- src/common/default_grid_sampler.rs | 2 +- src/common/global_histogram_binarizer.rs | 2 +- src/common/reedsolomon/generic_gf_poly.rs | 10 +++---- src/common/reedsolomon/reedsolomon_decoder.rs | 12 ++++----- src/common/reedsolomon/reedsolomon_encoder.rs | 8 ++---- src/datamatrix/data_matrix_writer.rs | 8 +++--- src/datamatrix/decoder/bit_matrix_parser.rs | 2 +- .../decoder/decoded_bit_stream_parser.rs | 2 +- .../detector/datamatrix_detector.rs | 2 +- src/datamatrix/encoder/c40_encoder.rs | 4 +-- src/datamatrix/encoder/edifact_encoder.rs | 8 ++---- src/datamatrix/encoder/encoder_context.rs | 2 +- src/datamatrix/encoder/error_correction.rs | 2 +- src/datamatrix/encoder/symbol_info.rs | 4 +-- src/helpers.rs | 20 +++++--------- src/luma_luma_source.rs | 2 +- src/luminance_source.rs | 6 ++--- .../detector/multi_finder_pattern_finder.rs | 4 +-- src/oned/code_128_writer.rs | 2 +- src/oned/ean_13_writer.rs | 4 +-- src/oned/ean_8_writer.rs | 4 +-- src/oned/itf_writer.rs | 2 +- src/oned/one_d_code_writer.rs | 6 ++--- src/oned/rss/expanded/binary_util.rs | 2 +- src/oned/upc_e_writer.rs | 8 ++---- src/pdf417/decoder/ec/modulus_poly.rs | 6 ++--- src/pdf417/encoder/pdf_417.rs | 4 +-- .../encoder/pdf_417_error_correction.rs | 6 ++--- .../encoder/pdf_417_high_level_encoder.rs | 6 ++--- src/planar_yuv_luminance_source.rs | 2 +- src/qrcode/decoder/version.rs | 6 ++--- src/qrcode/encoder/matrix_util.rs | 4 +-- src/qrcode/encoder/minimal_encoder.rs | 4 +-- src/qrcode/encoder/qrcode_encoder.rs | 26 +++++++------------ src/qrcode/qr_code_writer.rs | 6 ++--- src/rgb_luminance_source.rs | 2 +- src/svg_luminance_source.rs | 6 ++--- 47 files changed, 107 insertions(+), 167 deletions(-) diff --git a/src/aztec/decoder.rs b/src/aztec/decoder.rs index cb10079..f584b69 100644 --- a/src/aztec/decoder.rs +++ b/src/aztec/decoder.rs @@ -170,11 +170,7 @@ fn get_encoded_data(corrected_bits: &[bool]) -> Result { decoded_bytes.clear(); match n { 0 => result.push(29 as char), // translate FNC1 as ASCII 29 - 7 => { - return Err(Exceptions::format( - "FLG(7) is reserved and illegal".to_owned(), - )) - } // FLG(7) is reserved and illegal + 7 => return Err(Exceptions::format("FLG(7) is reserved and illegal")), // FLG(7) is reserved and illegal _ => { // ECI is decimal integer encoded as 1-6 codes in DIGIT mode let mut eci = 0; @@ -186,7 +182,7 @@ fn get_encoded_data(corrected_bits: &[bool]) -> Result { let next_digit = read_code(corrected_bits, index, 4); index += 4; if !(2..=11).contains(&next_digit) { - return Err(Exceptions::format("Not a decimal digit".to_owned())); + return Err(Exceptions::format("Not a decimal digit")); // Not a decimal digit } eci = eci * 10 + (next_digit - 2); @@ -194,7 +190,7 @@ fn get_encoded_data(corrected_bits: &[bool]) -> Result { } let charset_eci = CharacterSetECI::getCharacterSetECIByValue(eci); if charset_eci.is_err() { - return Err(Exceptions::format("Charset must exist".to_owned())); + return Err(Exceptions::format("Charset must exist")); } encdr = CharacterSetECI::getCharset(&charset_eci?); } @@ -238,7 +234,7 @@ fn get_encoded_data(corrected_bits: &[bool]) -> Result { if let Ok(str) = encdr.decode(&decoded_bytes, encoding::DecoderTrap::Strict) { result.push_str(&str); } else { - return Err(Exceptions::illegalState("bad encoding".to_owned())); + return Err(Exceptions::illegalState("bad encoding")); } // result.push_str(decodedBytes.toString(encoding.name())); //} catch (UnsupportedEncodingException uee) { @@ -290,7 +286,7 @@ fn get_character(table: Table, code: u32) -> Result<&'static str, Exceptions> { Table::Mixed => Ok(MIXED_TABLE[code as usize]), Table::Digit => Ok(DIGIT_TABLE[code as usize]), Table::Punct => Ok(PUNCT_TABLE[code as usize]), - _ => Err(Exceptions::illegalState("Bad table".to_owned())), + _ => Err(Exceptions::illegalState("Bad table")), } // switch (table) { // case UPPER: diff --git a/src/aztec/detector.rs b/src/aztec/detector.rs index aaedb29..097947b 100644 --- a/src/aztec/detector.rs +++ b/src/aztec/detector.rs @@ -127,7 +127,7 @@ impl<'a> Detector<'_> { || !self.is_valid(&bulls_eye_corners[2]) || !self.is_valid(&bulls_eye_corners[3]) { - return Err(Exceptions::notFound("no valid points".to_owned())); + return Err(Exceptions::notFound("no valid points")); } let length = 2 * self.nb_center_layers; // Get the bits around the bull's eye @@ -208,7 +208,7 @@ impl<'a> Detector<'_> { return Ok(shift); } } - Err(Exceptions::notFound("rotation failure".to_owned())) + Err(Exceptions::notFound("rotation failure")) } /** diff --git a/src/aztec/encoder/aztec_encoder.rs b/src/aztec/encoder/aztec_encoder.rs index 0d55196..baf7b17 100644 --- a/src/aztec/encoder/aztec_encoder.rs +++ b/src/aztec/encoder/aztec_encoder.rs @@ -188,13 +188,13 @@ pub fn encode_bytes_with_charset( stuffed_bits = stuffBits(&bits, word_size as usize)?; if stuffed_bits.getSize() as u32 + ecc_bits > usable_bits_in_layers { return Err(Exceptions::illegalArgument( - "Data to large for user specified layer".to_owned(), + "Data to large for user specified layer", )); } if compact && stuffed_bits.getSize() as u32 > word_size * 64 { // Compact format only allows 64 data words, though C4 can hold more words than that return Err(Exceptions::illegalArgument( - "Data to large for user specified layer".to_owned(), + "Data to large for user specified layer", )); } } else { @@ -208,7 +208,7 @@ pub fn encode_bytes_with_charset( // for (int i = 0; ; i++) { if i > MAX_NB_BITS { return Err(Exceptions::illegalArgument( - "Data too large for an Aztec code".to_owned(), + "Data too large for an Aztec code", )); } compact = i <= 3; diff --git a/src/aztec/encoder/high_level_encoder.rs b/src/aztec/encoder/high_level_encoder.rs index cb59088..108258f 100644 --- a/src/aztec/encoder/high_level_encoder.rs +++ b/src/aztec/encoder/high_level_encoder.rs @@ -248,9 +248,7 @@ impl HighLevelEncoder { initial_state = initial_state.appendFLGn(CharacterSetECI::getValue(&eci))?; } } else { - return Err(Exceptions::illegalArgument( - "No ECI code for character set".to_owned(), - )); + return Err(Exceptions::illegalArgument("No ECI code for character set")); } // if self.charset != null { // CharacterSetECI eci = CharacterSetECI.getCharacterSetECI(charset); diff --git a/src/aztec/encoder/state.rs b/src/aztec/encoder/state.rs index 9834cc7..bb82b84 100644 --- a/src/aztec/encoder/state.rs +++ b/src/aztec/encoder/state.rs @@ -81,7 +81,7 @@ impl State { } else */ if eci > 999999 { return Err(Exceptions::illegalArgument( - "ECI code must be between 0 and 999999".to_owned(), + "ECI code must be between 0 and 999999", )); // throw new IllegalArgumentException("ECI code must be between 0 and 999999"); } else { diff --git a/src/client/result/AddressBookParsedResult.rs b/src/client/result/AddressBookParsedResult.rs index b9e9418..28313d5 100644 --- a/src/client/result/AddressBookParsedResult.rs +++ b/src/client/result/AddressBookParsedResult.rs @@ -121,17 +121,17 @@ impl AddressBookParsedRXingResult { ) -> Result { if phone_numbers.len() != phone_types.len() && !phone_types.is_empty() { return Err(Exceptions::illegalArgument( - "Phone numbers and types lengths differ".to_owned(), + "Phone numbers and types lengths differ", )); } if emails.len() != email_types.len() && !email_types.is_empty() { return Err(Exceptions::illegalArgument( - "Emails and types lengths differ".to_owned(), + "Emails and types lengths differ", )); } if addresses.len() != address_types.len() && !address_types.is_empty() { return Err(Exceptions::illegalArgument( - "Addresses and types lengths differ".to_owned(), + "Addresses and types lengths differ", )); } Ok(Self { diff --git a/src/client/result/VINResultParser.rs b/src/client/result/VINResultParser.rs index 41b0757..842da2d 100644 --- a/src/client/result/VINResultParser.rs +++ b/src/client/result/VINResultParser.rs @@ -91,9 +91,7 @@ fn vin_char_value(c: char) -> Result { 'J'..='R' => Ok((c as u8 as u32 - b'J' as u32) + 1), 'S'..='Z' => Ok((c as u8 as u32 - b'S' as u32) + 2), '0'..='9' => Ok(c as u8 as u32 - b'0' as u32), - _ => Err(Exceptions::illegalArgument( - "vin char out of range".to_owned(), - )), + _ => Err(Exceptions::illegalArgument("vin char out of range")), } } @@ -104,7 +102,7 @@ fn vin_position_weight(position: usize) -> Result { 9 => Ok(0), 10..=17 => Ok(19 - position), _ => Err(Exceptions::illegalArgument( - "vin position weight out of bounds".to_owned(), + "vin position weight out of bounds", )), } } @@ -113,7 +111,7 @@ fn check_char(remainder: u8) -> Result { match remainder { 0..=9 => Ok((b'0' + remainder) as char), 10 => Ok('X'), - _ => Err(Exceptions::illegalArgument("remainder too high".to_owned())), + _ => Err(Exceptions::illegalArgument("remainder too high")), } } diff --git a/src/common/bit_array.rs b/src/common/bit_array.rs index 1ed68ba..6c5fd8c 100644 --- a/src/common/bit_array.rs +++ b/src/common/bit_array.rs @@ -254,7 +254,7 @@ impl BitArray { pub fn appendBits(&mut self, value: u32, num_bits: usize) -> Result<(), Exceptions> { if num_bits > 32 { return Err(Exceptions::illegalArgument( - "num bits must be between 0 and 32".to_owned(), + "num bits must be between 0 and 32", )); } @@ -286,7 +286,7 @@ impl BitArray { pub fn xor(&mut self, other: &BitArray) -> Result<(), Exceptions> { if self.size != other.size { - return Err(Exceptions::illegalArgument("Sizes don't match".to_owned())); + return Err(Exceptions::illegalArgument("Sizes don't match")); } for i in 0..self.bits.len() { //for (int i = 0; i < bits.length; i++) { diff --git a/src/common/bit_matrix.rs b/src/common/bit_matrix.rs index 10d70a3..2d0c893 100644 --- a/src/common/bit_matrix.rs +++ b/src/common/bit_matrix.rs @@ -66,7 +66,7 @@ impl BitMatrix { pub fn new(width: u32, height: u32) -> Result { if width < 1 || height < 1 { return Err(Exceptions::illegalArgument( - "Both dimensions must be greater than 0".to_owned(), + "Both dimensions must be greater than 0", )); } Ok(Self { @@ -151,9 +151,7 @@ impl BitMatrix { first_run = false; rowLength = bitsPos - rowStartPos; } else if bitsPos - rowStartPos != rowLength { - return Err(Exceptions::illegalArgument( - "row lengths do not match".to_owned(), - )); + return Err(Exceptions::illegalArgument("row lengths do not match")); } rowStartPos = bitsPos; nRows += 1; @@ -182,9 +180,7 @@ impl BitMatrix { // first_run = false; rowLength = bitsPos - rowStartPos; } else if bitsPos - rowStartPos != rowLength { - return Err(Exceptions::illegalArgument( - "row lengths do not match".to_owned(), - )); + return Err(Exceptions::illegalArgument("row lengths do not match")); } nRows += 1; } @@ -312,7 +308,7 @@ impl BitMatrix { if self.width != mask.width || self.height != mask.height || self.row_size != mask.row_size { return Err(Exceptions::illegalArgument( - "input matrix dimensions do not match".to_owned(), + "input matrix dimensions do not match", )); } // let mut rowArray = BitArray::with_size(self.width as usize); @@ -364,14 +360,14 @@ impl BitMatrix { // } if height < 1 || width < 1 { return Err(Exceptions::illegalArgument( - "height and width must be at least 1".to_owned(), + "height and width must be at least 1", )); } let right = left + width; let bottom = top + height; if bottom > self.height || right > self.width { return Err(Exceptions::illegalArgument( - "the region must fit inside the matrix".to_owned(), + "the region must fit inside the matrix", )); } for y in top..bottom { @@ -445,7 +441,7 @@ impl BitMatrix { Ok(()) } _ => Err(Exceptions::illegalArgument( - "degrees must be a multiple of 0, 90, 180, or 270".to_owned(), + "degrees must be a multiple of 0, 90, 180, or 270", )), } } diff --git a/src/common/character_set_eci.rs b/src/common/character_set_eci.rs index 97d9063..284127b 100644 --- a/src/common/character_set_eci.rs +++ b/src/common/character_set_eci.rs @@ -244,7 +244,7 @@ impl CharacterSetECI { 28 => Ok(CharacterSetECI::Big5), 29 => Ok(CharacterSetECI::GB18030), 30 => Ok(CharacterSetECI::EUC_KR), - _ => Err(Exceptions::notFound("Bad ECI Value".to_owned())), + _ => Err(Exceptions::notFound("Bad ECI Value")), } } diff --git a/src/common/default_grid_sampler.rs b/src/common/default_grid_sampler.rs index 3669669..f890394 100644 --- a/src/common/default_grid_sampler.rs +++ b/src/common/default_grid_sampler.rs @@ -99,7 +99,7 @@ impl GridSampler for DefaultGridSampler { if image .try_get(points[x] as u32, points[x + 1] as u32) .ok_or(Exceptions::notFound( - "index out of bounds, see documentation in file for explanation".to_owned(), + "index out of bounds, see documentation in file for explanation", ))? { // Black(-ish) pixel diff --git a/src/common/global_histogram_binarizer.rs b/src/common/global_histogram_binarizer.rs index 9c6a6af..b9e5431 100644 --- a/src/common/global_histogram_binarizer.rs +++ b/src/common/global_histogram_binarizer.rs @@ -234,7 +234,7 @@ impl GlobalHistogramBinarizer { // than waste time trying to decode the image, and risk false positives. if secondPeak - firstPeak <= numBuckets / 16 { return Err(Exceptions::notFound( - "secondPeak - firstPeak <= numBuckets / 16 ".to_owned(), + "secondPeak - firstPeak <= numBuckets / 16 ", )); } diff --git a/src/common/reedsolomon/generic_gf_poly.rs b/src/common/reedsolomon/generic_gf_poly.rs index 43eabda..f0a8d78 100644 --- a/src/common/reedsolomon/generic_gf_poly.rs +++ b/src/common/reedsolomon/generic_gf_poly.rs @@ -141,7 +141,7 @@ impl GenericGFPoly { pub fn addOrSubtract(&self, other: &GenericGFPoly) -> Result { if self.field != other.field { return Err(Exceptions::illegalArgument( - "GenericGFPolys do not have same GenericGF field".to_owned(), + "GenericGFPolys do not have same GenericGF field", )); } if self.isZero() { @@ -178,7 +178,7 @@ impl GenericGFPoly { if self.field != other.field { //if (!field.equals(other.field)) { return Err(Exceptions::illegalArgument( - "GenericGFPolys do not have same GenericGF field".to_owned(), + "GenericGFPolys do not have same GenericGF field", )); } if self.isZero() || other.isZero() { @@ -253,11 +253,11 @@ impl GenericGFPoly { ) -> Result<(GenericGFPoly, GenericGFPoly), Exceptions> { if self.field != other.field { return Err(Exceptions::illegalArgument( - "GenericGFPolys do not have same GenericGF field".to_owned(), + "GenericGFPolys do not have same GenericGF field", )); } if other.isZero() { - return Err(Exceptions::illegalArgument("Divide by 0".to_owned())); + return Err(Exceptions::illegalArgument("Divide by 0")); } let mut quotient = self.getZero(); @@ -266,7 +266,7 @@ impl GenericGFPoly { let denominator_leading_term = other.getCoefficient(other.getDegree()); let inverse_denominator_leading_term = match self.field.inverse(denominator_leading_term) { Ok(val) => val, - Err(_issue) => return Err(Exceptions::illegalArgument("arithmetic issue".to_owned())), + Err(_issue) => return Err(Exceptions::illegalArgument("arithmetic issue")), }; while remainder.getDegree() >= other.getDegree() && !remainder.isZero() { diff --git a/src/common/reedsolomon/reedsolomon_decoder.rs b/src/common/reedsolomon/reedsolomon_decoder.rs index ac28f67..292b967 100644 --- a/src/common/reedsolomon/reedsolomon_decoder.rs +++ b/src/common/reedsolomon/reedsolomon_decoder.rs @@ -92,11 +92,11 @@ impl ReedSolomonDecoder { //for (int i = 0; i < errorLocations.length; i++) { let log_value = self.field.log(errorLocations[i] as i32)?; if log_value > received.len() as i32 - 1 { - return Err(Exceptions::reedSolomon("Bad error location".to_owned())); + return Err(Exceptions::reedSolomon("Bad error location")); } let position: isize = received.len() as isize - 1 - log_value as isize; if position < 0 { - return Err(Exceptions::reedSolomon("Bad error location".to_owned())); + return Err(Exceptions::reedSolomon("Bad error location")); } received[position as usize] = GenericGF::addOrSubtract(received[position as usize], errorMagnitudes[i]); @@ -134,7 +134,7 @@ impl ReedSolomonDecoder { // Divide rLastLast by rLast, with quotient in q and remainder in r if rLast.isZero() { // Oops, Euclidean algorithm already terminated? - return Err(Exceptions::reedSolomon("r_{i-1} was zero".to_owned())); + return Err(Exceptions::reedSolomon("r_{i-1} was zero")); } r = rLastLast; let mut q = r.getZero(); @@ -160,12 +160,12 @@ impl ReedSolomonDecoder { let sigmaTildeAtZero = t.getCoefficient(0); if sigmaTildeAtZero == 0 { - return Err(Exceptions::reedSolomon("sigmaTilde(0) was zero".to_owned())); + return Err(Exceptions::reedSolomon("sigmaTilde(0) was zero")); } let inverse = match self.field.inverse(sigmaTildeAtZero) { Ok(res) => res, - Err(_err) => return Err(Exceptions::reedSolomon("ArithmetricException".to_owned())), + Err(_err) => return Err(Exceptions::reedSolomon("ArithmetricException")), }; let sigma = t.multiply_with_scalar(inverse); let omega = r.multiply_with_scalar(inverse); @@ -194,7 +194,7 @@ impl ReedSolomonDecoder { } if e != numErrors { return Err(Exceptions::reedSolomon( - "Error locator degree does not match number of roots".to_owned(), + "Error locator degree does not match number of roots", )); } Ok(result) diff --git a/src/common/reedsolomon/reedsolomon_encoder.rs b/src/common/reedsolomon/reedsolomon_encoder.rs index 3695fa4..1a6476e 100644 --- a/src/common/reedsolomon/reedsolomon_encoder.rs +++ b/src/common/reedsolomon/reedsolomon_encoder.rs @@ -73,15 +73,11 @@ impl ReedSolomonEncoder { pub fn encode(&mut self, to_encode: &mut Vec, ec_bytes: usize) -> Result<(), Exceptions> { if ec_bytes == 0 { - return Err(Exceptions::illegalArgument( - "No error correction bytes".to_owned(), - )); + return Err(Exceptions::illegalArgument("No error correction bytes")); } let data_bytes = to_encode.len() - ec_bytes; if data_bytes == 0 { - return Err(Exceptions::illegalArgument( - "No data bytes provided".to_owned(), - )); + return Err(Exceptions::illegalArgument("No data bytes provided")); } let fld = self.field; let generator = self.buildGenerator(ec_bytes); diff --git a/src/datamatrix/data_matrix_writer.rs b/src/datamatrix/data_matrix_writer.rs index 03b67ec..a86d301 100644 --- a/src/datamatrix/data_matrix_writer.rs +++ b/src/datamatrix/data_matrix_writer.rs @@ -60,9 +60,7 @@ impl Writer for DataMatrixWriter { hints: &crate::EncodingHintDictionary, ) -> Result { if contents.is_empty() { - return Err(Exceptions::illegalArgument( - "Found empty contents".to_owned(), - )); + return Err(Exceptions::illegalArgument("Found empty contents")); } if format != &BarcodeFormat::DATA_MATRIX { @@ -123,7 +121,7 @@ impl Writer for DataMatrixWriter { if hasEncodingHint { let Some(EncodeHintValue::CharacterSet(char_set_name)) = hints.get(&EncodeHintType::CHARACTER_SET) else { - return Err(Exceptions::illegalArgument("charset does not exist".to_owned())) + return Err(Exceptions::illegalArgument("charset does not exist")) }; charset = encoding::label::encoding_from_whatwg_label(char_set_name); // charset = Charset.forName(hints.get(EncodeHintType.CHARACTER_SET).toString()); @@ -157,7 +155,7 @@ impl Writer for DataMatrixWriter { let symbol_lookup = SymbolInfoLookup::new(); let Some(symbolInfo) = symbol_lookup.lookup_with_codewords_shape_size_fail(encoded.chars().count() as u32, *shape, &minSize, &maxSize, true)? else { - return Err(Exceptions::notFound("symbol info is bad".to_owned())) + return Err(Exceptions::notFound("symbol info is bad")) }; //2. step: ECC generation diff --git a/src/datamatrix/decoder/bit_matrix_parser.rs b/src/datamatrix/decoder/bit_matrix_parser.rs index eccd707..635ea6b 100644 --- a/src/datamatrix/decoder/bit_matrix_parser.rs +++ b/src/datamatrix/decoder/bit_matrix_parser.rs @@ -457,7 +457,7 @@ impl BitMatrixParser { if bitMatrix.getHeight() != symbolSizeRows { return Err(Exceptions::illegalArgument( - "Dimension of bitMatrix must match the version size".to_owned(), + "Dimension of bitMatrix must match the version size", )); } diff --git a/src/datamatrix/decoder/decoded_bit_stream_parser.rs b/src/datamatrix/decoder/decoded_bit_stream_parser.rs index 95331da..946417e 100644 --- a/src/datamatrix/decoder/decoded_bit_stream_parser.rs +++ b/src/datamatrix/decoder/decoded_bit_stream_parser.rs @@ -279,7 +279,7 @@ fn decodeAsciiSegment( // Must be first ISO 16022:2006 5.6.1 { return Err(Exceptions::format( - "structured append tag must be first code word".to_owned(), + "structured append tag must be first code word", )); } parse_structured_append(bits, &mut sai)?; diff --git a/src/datamatrix/detector/datamatrix_detector.rs b/src/datamatrix/detector/datamatrix_detector.rs index 7a12213..bf6b39f 100644 --- a/src/datamatrix/detector/datamatrix_detector.rs +++ b/src/datamatrix/detector/datamatrix_detector.rs @@ -53,7 +53,7 @@ impl<'a> Detector<'_> { if let Some(point) = self.correctTopRight(&points) { points[3] = point; } else { - return Err(Exceptions::notFound("point 4 unfound".to_owned())); + return Err(Exceptions::notFound("point 4 unfound")); } // points[3] = self.correctTopRight(&points); // if points[3] == null { diff --git a/src/datamatrix/encoder/c40_encoder.rs b/src/datamatrix/encoder/c40_encoder.rs index ff00213..e3e6a45 100644 --- a/src/datamatrix/encoder/c40_encoder.rs +++ b/src/datamatrix/encoder/c40_encoder.rs @@ -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); diff --git a/src/datamatrix/encoder/edifact_encoder.rs b/src/datamatrix/encoder/edifact_encoder.rs index c42f252..9ae75b5 100644 --- a/src/datamatrix/encoder/edifact_encoder.rs +++ b/src/datamatrix/encoder/edifact_encoder.rs @@ -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 { 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() diff --git a/src/datamatrix/encoder/encoder_context.rs b/src/datamatrix/encoder/encoder_context.rs index f9eebf7..5d34815 100644 --- a/src/datamatrix/encoder/encoder_context.rs +++ b/src/datamatrix/encoder/encoder_context.rs @@ -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 { diff --git a/src/datamatrix/encoder/error_correction.rs b/src/datamatrix/encoder/error_correction.rs index 69dabb6..9e7a023 100644 --- a/src/datamatrix/encoder/error_correction.rs +++ b/src/datamatrix/encoder/error_correction.rs @@ -155,7 +155,7 @@ const ALOG: [u32; 255] = { pub fn encodeECC200(codewords: &str, symbolInfo: &SymbolInfo) -> Result { 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( diff --git a/src/datamatrix/encoder/symbol_info.rs b/src/datamatrix/encoder/symbol_info.rs index 0e79c8f..40df3f6 100644 --- a/src/datamatrix/encoder/symbol_info.rs +++ b/src/datamatrix/encoder/symbol_info.rs @@ -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", )), } } diff --git a/src/helpers.rs b/src/helpers.rs index 592b6d9..640391e 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -35,20 +35,16 @@ pub fn detect_in_svg_with_hints( let path = PathBuf::from(file_name); if !path.exists() { - return Err(Exceptions::illegalArgument( - "file does not exist".to_owned(), - )); + return Err(Exceptions::illegalArgument("file does not exist")); } let Ok(mut file) = File::open(path) else { - return Err(Exceptions::illegalArgument("file cannot be opened".to_owned())); + return Err(Exceptions::illegalArgument("file cannot be opened")); }; let mut svg_data = Vec::new(); if file.read_to_end(&mut svg_data).is_err() { - return Err(Exceptions::illegalArgument( - "file cannot be read".to_owned(), - )); + return Err(Exceptions::illegalArgument("file cannot be read")); } let mut multi_format_reader = MultiFormatReader::default(); @@ -88,20 +84,16 @@ pub fn detect_multiple_in_svg_with_hints( let path = PathBuf::from(file_name); if !path.exists() { - return Err(Exceptions::illegalArgument( - "file does not exist".to_owned(), - )); + return Err(Exceptions::illegalArgument("file does not exist")); } let Ok(mut file) = File::open(path) else { - return Err(Exceptions::illegalArgument("file cannot be opened".to_owned())); + return Err(Exceptions::illegalArgument("file cannot be opened")); }; let mut svg_data = Vec::new(); if file.read_to_end(&mut svg_data).is_err() { - return Err(Exceptions::illegalArgument( - "file cannot be read".to_owned(), - )); + return Err(Exceptions::illegalArgument("file cannot be read")); } let multi_format_reader = MultiFormatReader::default(); diff --git a/src/luma_luma_source.rs b/src/luma_luma_source.rs index 5f60e7b..497844c 100644 --- a/src/luma_luma_source.rs +++ b/src/luma_luma_source.rs @@ -96,7 +96,7 @@ impl LuminanceSource for Luma8LuminanceSource { fn rotateCounterClockwise45(&self) -> Result, crate::Exceptions> { Err(crate::Exceptions::unsupportedOperation( - "This luminance source does not support rotation by 45 degrees.".to_owned(), + "This luminance source does not support rotation by 45 degrees.", )) } } diff --git a/src/luminance_source.rs b/src/luminance_source.rs index 21954bf..2c55378 100644 --- a/src/luminance_source.rs +++ b/src/luminance_source.rs @@ -92,7 +92,7 @@ pub trait LuminanceSource { _height: usize, ) -> Result, Exceptions> { Err(Exceptions::unsupportedOperation( - "This luminance source does not support cropping.".to_owned(), + "This luminance source does not support cropping.", )) } @@ -119,7 +119,7 @@ pub trait LuminanceSource { */ fn rotateCounterClockwise(&self) -> Result, Exceptions> { Err(Exceptions::unsupportedOperation( - "This luminance source does not support rotation by 90 degrees.".to_owned(), + "This luminance source does not support rotation by 90 degrees.", )) } @@ -131,7 +131,7 @@ pub trait LuminanceSource { */ fn rotateCounterClockwise45(&self) -> Result, Exceptions> { Err(Exceptions::unsupportedOperation( - "This luminance source does not support rotation by 45 degrees.".to_owned(), + "This luminance source does not support rotation by 45 degrees.", )) } diff --git a/src/multi/qrcode/detector/multi_finder_pattern_finder.rs b/src/multi/qrcode/detector/multi_finder_pattern_finder.rs index 49803d6..43d9a7b 100644 --- a/src/multi/qrcode/detector/multi_finder_pattern_finder.rs +++ b/src/multi/qrcode/detector/multi_finder_pattern_finder.rs @@ -93,9 +93,7 @@ impl<'a> MultiFinderPatternFinder<'_> { if size < 3 { // Couldn't find enough finder patterns - return Err(Exceptions::notFound( - "Couldn't find enough finder patterns".to_owned(), - )); + return Err(Exceptions::notFound("Couldn't find enough finder patterns")); } /* diff --git a/src/oned/code_128_writer.rs b/src/oned/code_128_writer.rs index f08e1d1..e8c0c6d 100644 --- a/src/oned/code_128_writer.rs +++ b/src/oned/code_128_writer.rs @@ -249,7 +249,7 @@ fn encodeFast(contents: &str, forcedCodeSet: i32) -> Result, 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 diff --git a/src/oned/ean_13_writer.rs b/src/oned/ean_13_writer.rs index f585dc6..05c094a 100644 --- a/src/oned/ean_13_writer.rs +++ b/src/oned/ean_13_writer.rs @@ -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")); } } _ => { diff --git a/src/oned/ean_8_writer.rs b/src/oned/ean_8_writer.rs index 3191bd4..9857d35 100644 --- a/src/oned/ean_8_writer.rs +++ b/src/oned/ean_8_writer.rs @@ -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")); } } _ => { diff --git a/src/oned/itf_writer.rs b/src/oned/itf_writer.rs index 57d14d2..ffd32b3 100644 --- a/src/oned/itf_writer.rs +++ b/src/oned/itf_writer.rs @@ -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 { diff --git a/src/oned/one_d_code_writer.rs b/src/oned/one_d_code_writer.rs index 0ec8f3d..315f54d 100644 --- a/src/oned/one_d_code_writer.rs +++ b/src/oned/one_d_code_writer.rs @@ -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 { 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 { diff --git a/src/oned/rss/expanded/binary_util.rs b/src/oned/rss/expanded/binary_util.rs index a3ebc7a..5493ef4 100644 --- a/src/oned/rss/expanded/binary_util.rs +++ b/src/oned/rss/expanded/binary_util.rs @@ -51,7 +51,7 @@ pub fn buildBitArrayFromString(data: &str) -> Result { 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; } diff --git a/src/oned/upc_e_writer.rs b/src/oned/upc_e_writer.rs index 9a4bf2c..90cf4af 100644 --- a/src/oned/upc_e_writer.rs +++ b/src/oned/upc_e_writer.rs @@ -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 diff --git a/src/pdf417/decoder/ec/modulus_poly.rs b/src/pdf417/decoder/ec/modulus_poly.rs index 694c8f9..693c4bd 100644 --- a/src/pdf417/decoder/ec/modulus_poly.rs +++ b/src/pdf417/decoder/ec/modulus_poly.rs @@ -127,7 +127,7 @@ impl ModulusPoly { pub fn add(&self, other: Rc) -> Result, 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) -> Result, 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) -> Result, 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() { diff --git a/src/pdf417/encoder/pdf_417.rs b/src/pdf417/encoder/pdf_417.rs index 406670d..e502971 100644 --- a/src/pdf417/encoder/pdf_417.rs +++ b/src/pdf417/encoder/pdf_417.rs @@ -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")) } /** diff --git a/src/pdf417/encoder/pdf_417_error_correction.rs b/src/pdf417/encoder/pdf_417_error_correction.rs index 41d71c7..a24d6e0 100644 --- a/src/pdf417/encoder/pdf_417_error_correction.rs +++ b/src/pdf417/encoder/pdf_417_error_correction.rs @@ -120,7 +120,7 @@ static EC_COEFFICIENTS: Lazy<[Vec; 9]> = Lazy::new(|| { pub fn getErrorCorrectionCodewordCount(errorCorrectionLevel: u32) -> Result { 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 Result { 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 Result { 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( if !can_encode { if TypeId::of::() != TypeId::of::() { - 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!( diff --git a/src/planar_yuv_luminance_source.rs b/src/planar_yuv_luminance_source.rs index b2bd6f2..653e50b 100644 --- a/src/planar_yuv_luminance_source.rs +++ b/src/planar_yuv_luminance_source.rs @@ -167,7 +167,7 @@ impl PlanarYUVLuminanceSource { ) -> Result { if left + width > data_width || top + height > data_height { return Err(Exceptions::illegalArgument( - "Crop rectangle does not fit within image data.".to_owned(), + "Crop rectangle does not fit within image data.", )); } diff --git a/src/qrcode/decoder/version.rs b/src/qrcode/decoder/version.rs index 2710ce6..a1fc8ec 100755 --- a/src/qrcode/decoder/version.rs +++ b/src/qrcode/decoder/version.rs @@ -101,16 +101,14 @@ impl Version { dimension: u32, ) -> Result<&'static Version, Exceptions> { if dimension % 4 != 1 { - return Err(Exceptions::format("dimension incorrect".to_owned())); + return Err(Exceptions::format("dimension incorrect")); } Self::getVersionForNumber((dimension - 17) / 4) } pub fn getVersionForNumber(versionNumber: u32) -> Result<&'static Version, Exceptions> { if !(1..=40).contains(&versionNumber) { - return Err(Exceptions::illegalArgument( - "version out of spec".to_owned(), - )); + return Err(Exceptions::illegalArgument("version out of spec")); } Ok(&VERSIONS[versionNumber as usize - 1]) } diff --git a/src/qrcode/encoder/matrix_util.rs b/src/qrcode/encoder/matrix_util.rs index 3c20946..1368b3c 100644 --- a/src/qrcode/encoder/matrix_util.rs +++ b/src/qrcode/encoder/matrix_util.rs @@ -323,7 +323,7 @@ pub fn findMSBSet(value: u32) -> u32 { // operations. We don't care if coefficients are positive or negative. pub fn calculateBCHCode(value: u32, poly: u32) -> Result { if poly == 0 { - return Err(Exceptions::illegalArgument("0 polynomial".to_owned())); + return Err(Exceptions::illegalArgument("0 polynomial")); } let mut value = value; // If poly is "1 1111 0010 0101" (version info poly), msbSetInPoly is 13. We'll subtract 1 @@ -347,7 +347,7 @@ pub fn makeTypeInfoBits( bits: &mut BitArray, ) -> Result<(), Exceptions> { if !QRCode::isValidMaskPattern(maskPattern as i32) { - return Err(Exceptions::writer("Invalid mask pattern".to_owned())); + return Err(Exceptions::writer("Invalid mask pattern")); } let typeInfo = (ecLevel.get_value() << 3) as u32 | maskPattern; bits.appendBits(typeInfo, 5)?; diff --git a/src/qrcode/encoder/minimal_encoder.rs b/src/qrcode/encoder/minimal_encoder.rs index 17926b2..d7c16ca 100644 --- a/src/qrcode/encoder/minimal_encoder.rs +++ b/src/qrcode/encoder/minimal_encoder.rs @@ -186,9 +186,7 @@ impl MinimalEncoder { } } if smallestRXingResult < 0 { - return Err(Exceptions::writer( - "Data too big for any version".to_owned(), - )); + return Err(Exceptions::writer("Data too big for any version")); } Ok(results[smallestRXingResult as usize].clone()) } diff --git a/src/qrcode/encoder/qrcode_encoder.rs b/src/qrcode/encoder/qrcode_encoder.rs index c0f36ec..723d714 100644 --- a/src/qrcode/encoder/qrcode_encoder.rs +++ b/src/qrcode/encoder/qrcode_encoder.rs @@ -180,9 +180,7 @@ pub fn encode_with_hints( version = Version::getVersionForNumber(versionNumber)?; let bitsNeeded = calculateBitsNeeded(mode, &header_bits, &data_bits, version); if !willFit(bitsNeeded, version, &ec_level) { - return Err(Exceptions::writer( - "Data too big for requested version".to_owned(), - )); + return Err(Exceptions::writer("Data too big for requested version")); } } else { version = recommendVersion(&ec_level, mode, &header_bits, &data_bits)?; @@ -446,9 +444,7 @@ pub fn terminateBits(num_data_bytes: u32, bits: &mut BitArray) -> Result<(), Exc bits.appendBits(if (i & 0x01) == 0 { 0xEC } else { 0x11 }, 8)?; } if bits.getSize() != capacity as usize { - return Err(Exceptions::writer( - "Bits size does not equal capacity".to_owned(), - )); + return Err(Exceptions::writer("Bits size does not equal capacity")); } Ok(()) } @@ -467,7 +463,7 @@ pub fn getNumDataBytesAndNumECBytesForBlockID( // numECBytesInBlock: &mut [u32], ) -> Result<(u32, u32), Exceptions> { if block_id >= num_rsblocks { - return Err(Exceptions::writer("Block ID too large".to_owned())); + return Err(Exceptions::writer("Block ID too large")); } // numRsBlocksInGroup2 = 196 % 5 = 1 let num_rs_blocks_in_group2 = num_total_bytes % num_rsblocks; @@ -488,18 +484,18 @@ pub fn getNumDataBytesAndNumECBytesForBlockID( // Sanity checks. // 26 = 26 if num_ec_bytes_in_group1 != numEcBytesInGroup2 { - return Err(Exceptions::writer("EC bytes mismatch".to_owned())); + return Err(Exceptions::writer("EC bytes mismatch")); } // 5 = 4 + 1. if num_rsblocks != num_rs_blocks_in_group1 + num_rs_blocks_in_group2 { - return Err(Exceptions::writer("RS blocks mismatch".to_owned())); + return Err(Exceptions::writer("RS blocks mismatch")); } // 196 = (13 + 26) * 4 + (14 + 26) * 1 if num_total_bytes != ((num_data_bytes_in_group1 + num_ec_bytes_in_group1) * num_rs_blocks_in_group1) + ((num_data_bytes_in_group2 + numEcBytesInGroup2) * num_rs_blocks_in_group2) { - return Err(Exceptions::writer("total bytes mismatch".to_owned())); + return Err(Exceptions::writer("total bytes mismatch")); } Ok(if block_id < num_rs_blocks_in_group1 { @@ -522,7 +518,7 @@ pub fn interleaveWithECBytes( // "bits" must have "getNumDataBytes" bytes of data. if bits.getSizeInBytes() as u32 != num_data_bytes { return Err(Exceptions::writer( - "Number of bits and data bytes does not match".to_owned(), + "Number of bits and data bytes does not match", )); } @@ -556,9 +552,7 @@ pub fn interleaveWithECBytes( data_bytes_offset += numDataBytesInBlock as usize; } if num_data_bytes != data_bytes_offset as u32 { - return Err(Exceptions::writer( - "Data bytes does not match offset".to_owned(), - )); + return Err(Exceptions::writer("Data bytes does not match offset")); } let mut result = BitArray::new(); @@ -757,7 +751,7 @@ pub fn appendKanjiBytes(content: &str, bits: &mut BitArray) -> Result<(), Except .encode(content, encoding::EncoderTrap::Strict) .map_err(|e| Exceptions::writer(format!("error {e}")))?; if bytes.len() % 2 != 0 { - return Err(Exceptions::writer("Kanji byte size not even".to_owned())); + return Err(Exceptions::writer("Kanji byte size not even")); } let max_i = bytes.len() - 1; // bytes.length must be even let mut i = 0; @@ -772,7 +766,7 @@ pub fn appendKanjiBytes(content: &str, bits: &mut BitArray) -> Result<(), Except subtracted = code as i32 - 0xc140; } if subtracted == -1 { - return Err(Exceptions::writer("Invalid byte sequence".to_owned())); + return Err(Exceptions::writer("Invalid byte sequence")); } let encoded = ((subtracted >> 8) * 0xc0) + (subtracted & 0xff); bits.appendBits(encoded as u32, 13)?; diff --git a/src/qrcode/qr_code_writer.rs b/src/qrcode/qr_code_writer.rs index 7bbd359..e9707e6 100644 --- a/src/qrcode/qr_code_writer.rs +++ b/src/qrcode/qr_code_writer.rs @@ -58,9 +58,7 @@ impl Writer for QRCodeWriter { hints: &crate::EncodingHintDictionary, ) -> Result { if contents.is_empty() { - return Err(Exceptions::illegalArgument( - "found empty contents".to_owned(), - )); + return Err(Exceptions::illegalArgument("found empty contents")); } if format != &BarcodeFormat::QR_CODE { @@ -110,7 +108,7 @@ impl QRCodeWriter { ) -> Result { let input = code.getMatrix(); if input.is_none() { - return Err(Exceptions::illegalState("matrix is empty".to_owned())); + return Err(Exceptions::illegalState("matrix is empty")); } let input = input.as_ref().ok_or(Exceptions::illegalStateEmpty())?; diff --git a/src/rgb_luminance_source.rs b/src/rgb_luminance_source.rs index 3c4c3bf..2201910 100644 --- a/src/rgb_luminance_source.rs +++ b/src/rgb_luminance_source.rs @@ -180,7 +180,7 @@ impl RGBLuminanceSource { ) -> Result { if left + width > data_width || top + height > data_height { return Err(Exceptions::illegalArgument( - "Crop rectangle does not fit within image data.".to_owned(), + "Crop rectangle does not fit within image data.", )); } Ok(Self { diff --git a/src/svg_luminance_source.rs b/src/svg_luminance_source.rs index 2785e0f..5490ce7 100644 --- a/src/svg_luminance_source.rs +++ b/src/svg_luminance_source.rs @@ -60,7 +60,7 @@ impl SVGLuminanceSource { }; let Some(mut pixmap) = resvg::tiny_skia::Pixmap::new(tree.size.width() as u32, tree.size.height() as u32) else { - return Err(Exceptions::format("could not create pixmap".to_owned())); + return Err(Exceptions::format("could not create pixmap")); }; resvg::render( @@ -71,11 +71,11 @@ impl SVGLuminanceSource { ); let Some(buffer) = RgbaImage::from_raw(tree.size.width() as u32, tree.size.height() as u32, pixmap.data().to_vec()) else { - return Err(Exceptions::format("could not create image buffer".to_owned())); + return Err(Exceptions::format("could not create image buffer")); }; // let Ok(image) = image::load_from_memory_with_format(pixmap.data(), image::ImageFormat::Bmp) else { - // return Err(Exceptions::format("could not generate image".to_owned())); + // return Err(Exceptions::format("could not generate image")); // }; Ok(Self(BufferedImageLuminanceSource::new(DynamicImage::from(