From 955fa1609eefb23fa3d324db1e57781f33b8fe3c Mon Sep 17 00:00:00 2001 From: Ryan Lopopolo Date: Sun, 21 May 2023 17:45:05 -0700 Subject: [PATCH] lint: `clippy::cast_lossless` and `clippy::unreadable_literal` lints --- src/utf8.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/utf8.rs b/src/utf8.rs index f096e39..054740c 100644 --- a/src/utf8.rs +++ b/src/utf8.rs @@ -813,10 +813,11 @@ pub fn decode_last_lossy>(slice: B) -> (char, usize) { #[inline] pub fn decode_step(state: &mut usize, cp: &mut u32, b: u8) { let class = CLASSES[b as usize]; + let b = u32::from(b); if *state == ACCEPT { - *cp = (0xFF >> class) & (b as u32); + *cp = (0xFF >> class) & b; } else { - *cp = (b as u32 & 0b111111) | (*cp << 6); + *cp = (b & 0b0011_1111) | (*cp << 6); } *state = STATES_FORWARD[*state + class as usize] as usize; }