Resolve more linter warnings

This commit is contained in:
2022-08-27 14:47:56 -04:00
parent 0951a6ab3e
commit bac75acd2c
14 changed files with 175 additions and 172 deletions

View File

@@ -43,10 +43,10 @@ impl BytesBase64 {
v.push(0);
}
let mut result = vec![
(v[0] & 0b11111100) >> 2,
(v[0] & 0b00000011) << 4 | (v[1] & 0b11110000) >> 4,
(v[1] & 0b00001111) << 2 | (v[2] & 0b11000000) >> 6,
(v[2] & 0b00111111),
(v[0] & 0b1111_1100) >> 2,
(v[0] & 0b0000_0011) << 4 | (v[1] & 0b1111_0000) >> 4,
(v[1] & 0b0000_1111) << 2 | (v[2] & 0b1100_0000) >> 6,
(v[2] & 0b0011_1111),
];
// removed padded bytes
for _ in c.len()..3 {
@@ -58,7 +58,6 @@ impl BytesBase64 {
}
pub fn to_bytes(&self) -> Bytes {
let BytesBase64(v) = self;
fn to_bytes(c: &[u8]) -> Vec<u8> {
let mut v = c.to_vec();
// pad with bytes for conversion
@@ -66,9 +65,9 @@ impl BytesBase64 {
v.push(0);
}
let mut result: Vec<u8> = vec![
((v[0] & 0b00111111) << 2) | ((v[1] & 0b00110000) >> 4),
((v[1] & 0b00001111) << 4) | ((v[2] & 0b00111100) >> 2),
((v[2] & 0b00000011) << 6) | (v[3] & 0b00111111),
((v[0] & 0b0011_1111) << 2) | ((v[1] & 0b0011_0000) >> 4),
((v[1] & 0b0000_1111) << 4) | ((v[2] & 0b0011_1100) >> 2),
((v[2] & 0b0000_0011) << 6) | (v[3] & 0b0011_1111),
];
// removed padded bytes
for _ in c.len()..4 {
@@ -76,6 +75,7 @@ impl BytesBase64 {
}
result
}
let BytesBase64(v) = self;
Bytes(v.chunks(4).flat_map(to_bytes).collect())
}
@@ -88,9 +88,7 @@ impl BytesBase64 {
'0'..='9' => r.push((c as u8) - b'0' + 52),
'+' => r.push(62),
'/' => r.push(63),
'\n' => (),
'=' => (),
' ' => (),
'\n' | '=' | ' ' => (),
_ => {
return Err(format!("Unexpected character '{}'", c));
}