Info
This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: Out od curiosity, why Rust insisted on the case?
I have the following code,
let (len, mut shift) =
match input[1] >> 1 {
len @ 0..=125 => (len as u64, 2_usize),
126 => (input[2] as u64 | (input[3] as u64) << 8, 4_usize),
127 => (input[9] as u64 | (input[8] as u64)<<8 | (input[7] as u64)<<16 |
(input[6] as u64)<<24 | (input[4] as u64)<<32 | (input[4] as u64)<<40 | (input[3] as u64)<<48 | (input[2] as u64)<<56, 10_usize),
128_u8..=u8::MAX => todo!()
};
Since I do the right shift on 1 and it isn't cyclic, the value can't exceed 127, however Rust insisted on the last condition. Why? Did I miss something?
4 posts - 3 participants
🏷️ rust_feed