style: cargo fmt + clippy fix 全项目格式化

This commit is contained in:
2026-06-16 23:58:15 +08:00
parent 9201cd820c
commit 30af4ff607
16 changed files with 1298 additions and 165 deletions
+32 -7
View File
@@ -22,16 +22,38 @@ impl Mode {
pub fn count_bits(self, version: u8) -> u8 {
match self {
Mode::Numeric => {
if version <= 9 { 10 } else if version <= 26 { 12 } else { 14 }
if version <= 9 {
10
} else if version <= 26 {
12
} else {
14
}
}
Mode::Alphanumeric => {
if version <= 9 { 9 } else if version <= 26 { 11 } else { 13 }
if version <= 9 {
9
} else if version <= 26 {
11
} else {
13
}
}
Mode::Byte => {
if version <= 9 { 8 } else { 16 }
if version <= 9 {
8
} else {
16
}
}
Mode::Kanji => {
if version <= 9 { 8 } else if version <= 26 { 10 } else { 12 }
if version <= 9 {
8
} else if version <= 26 {
10
} else {
12
}
}
}
}
@@ -40,7 +62,8 @@ impl Mode {
/// 数字模式编码: 每 3 位数字 → 10 bit
pub fn encode_numeric(input: &str) -> Vec<bool> {
let mut bits = Vec::new();
let chars: Vec<u8> = input.chars()
let chars: Vec<u8> = input
.chars()
.filter_map(|c| c.to_digit(10).map(|d| d as u8))
.collect();
@@ -65,9 +88,11 @@ const ALPHANUMERIC_CHARS: &[u8] = b"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./
/// 字母数字模式编码: 每 2 个字符 → 11 bit
pub fn encode_alphanumeric(input: &str) -> Vec<bool> {
let values: Vec<u8> = input.chars()
let values: Vec<u8> = input
.chars()
.filter_map(|c| {
ALPHANUMERIC_CHARS.iter()
ALPHANUMERIC_CHARS
.iter()
.position(|&x| x == c as u8)
.map(|i| i as u8)
})