cargo clippy && fmt

This commit is contained in:
Henry Schimke
2023-03-02 15:54:40 -06:00
parent a0b8b68869
commit 9431031147
28 changed files with 111 additions and 135 deletions

View File

@@ -203,8 +203,7 @@ fn decodeHanziSegment(bits: &mut BitSource, result: &mut String, count: usize) -
count -= 1;
}
let gb_encoder =
CharacterSetECI::GB18030;
let gb_encoder = CharacterSetECI::GB18030;
let encode_string = gb_encoder
.decode(&buffer)
.map_err(|e| Exceptions::parse_with(format!("unable to decode buffer {buffer:?}: {e}")))?;
@@ -321,13 +320,9 @@ fn decodeByteSegment(
// )
};
let encode_string =
encoding
.decode(&readBytes)
.map_err(|e| {
Exceptions::parse_with(format!("unable to decode buffer {readBytes:?}: {e}"))
})?
;
let encode_string = encoding.decode(&readBytes).map_err(|e| {
Exceptions::parse_with(format!("unable to decode buffer {readBytes:?}: {e}"))
})?;
result.push_str(&encode_string);
byteSegments.push(readBytes);

View File

@@ -28,8 +28,7 @@ use once_cell::sync::Lazy;
use super::QRCode;
static SHIFT_JIS_CHARSET: Lazy<CharacterSetECI> =
Lazy::new(|| CharacterSetECI::SJIS);
static SHIFT_JIS_CHARSET: Lazy<CharacterSetECI> = Lazy::new(|| CharacterSetECI::SJIS);
/**
* @author satorux@google.com (Satoru Takabayashi) - creator

View File

@@ -17,7 +17,7 @@
use std::{fmt, rc::Rc};
use crate::{
common::{BitArray, ECIEncoderSet, Result, CharacterSetECI},
common::{BitArray, CharacterSetECI, ECIEncoderSet, Result},
qrcode::decoder::{ErrorCorrectionLevel, Mode, Version, VersionRef},
Exceptions,
};
@@ -1042,7 +1042,7 @@ impl fmt::Display for RXingResultNode {
result.push('(');
if self.mode == Mode::ECI {
result.push_str(
&self.encoders
self.encoders
.getCharset(self.charsetEncoderIndex)
.ok_or(fmt::Error)?
.getCharsetName(),

View File

@@ -32,8 +32,7 @@ use crate::{
use super::{mask_util, matrix_util, BlockPair, ByteMatrix, MinimalEncoder, QRCode};
static SHIFT_JIS_CHARSET: CharacterSetECI =
CharacterSetECI::SJIS;
static SHIFT_JIS_CHARSET: CharacterSetECI = CharacterSetECI::SJIS;
// The original table is defined in the table 5 of JISX0510:2004 (p.19).
const ALPHANUMERIC_TABLE: [i8; 96] = [
@@ -97,8 +96,7 @@ pub fn encode_with_hints(
let mut has_encoding_hint = hints.contains_key(&EncodeHintType::CHARACTER_SET);
if has_encoding_hint {
if let Some(EncodeHintValue::CharacterSet(v)) = hints.get(&EncodeHintType::CHARACTER_SET) {
encoding =
Some(CharacterSetECI::getCharacterSetECIByName(v).ok_or(Exceptions::WRITER)?)
encoding = Some(CharacterSetECI::getCharacterSetECIByName(v).ok_or(Exceptions::WRITER)?)
}
}
@@ -122,9 +120,7 @@ pub fn encode_with_hints(
//Switch to default encoding
let encoding = if let Some(encoding) = encoding {
encoding
} else if let Ok(_encs) =
DEFAULT_BYTE_MODE_ENCODING.encode(content)
{
} else if let Ok(_encs) = DEFAULT_BYTE_MODE_ENCODING.encode(content) {
DEFAULT_BYTE_MODE_ENCODING
} else {
has_encoding_hint = true;
@@ -720,7 +716,11 @@ pub fn appendAlphanumericBytes(content: &str, bits: &mut BitArray) -> Result<()>
Ok(())
}
pub fn append8BitBytes(content: &str, bits: &mut BitArray, encoding: CharacterSetECI) -> Result<()> {
pub fn append8BitBytes(
content: &str,
bits: &mut BitArray,
encoding: CharacterSetECI,
) -> Result<()> {
let bytes = encoding
.encode(content)
.map_err(|e| Exceptions::writer_with(format!("error {e}")))?;