diff --git a/src/config/network/helper.rs b/src/config/network/helper.rs index c4c4b63b..0449caac 100644 --- a/src/config/network/helper.rs +++ b/src/config/network/helper.rs @@ -51,6 +51,7 @@ pub static IPV4_REVERSE_MASK: &[&str] = &[ lazy_static! { pub static ref IPV4_MASK_HASH_LOCALNET: HashMap<&'static str, u8> = { let mut map = HashMap::new(); + #[allow(clippy::needless_range_loop)] for i in 8..32 { map.insert(IPV4_REVERSE_MASK[i], i as u8); } diff --git a/src/server/config.rs b/src/server/config.rs index c7300668..8306f1c2 100644 --- a/src/server/config.rs +++ b/src/server/config.rs @@ -57,9 +57,9 @@ impl ApiConfig { prefix.push_str(components[0]); if let Some(subdir) = self.aliases.get(&prefix) { filename.push(subdir); - for i in 1..comp_len { filename.push(components[i]) } + components.iter().skip(1).for_each(|comp| filename.push(comp)); } else { - for i in 0..comp_len { filename.push(components[i]) } + components.iter().for_each(|comp| filename.push(comp)); } } filename diff --git a/src/tape/drive/volume_statistics.rs b/src/tape/drive/volume_statistics.rs index 5657d3ef..a6a8a26c 100644 --- a/src/tape/drive/volume_statistics.rs +++ b/src/tape/drive/volume_statistics.rs @@ -95,19 +95,16 @@ fn decode_volume_statistics(data: &[u8]) -> Result let read_be_counter = |reader: &mut &[u8], len: u8| { let len = len as usize; - if len == 0 || len > 8 { bail!("invalid conter size '{}'", len); } let mut buffer = [0u8; 8]; reader.read_exact(&mut buffer[..len])?; - let mut value: u64 = 0; - - for i in 0..len { - value <<= 8; - value |= buffer[i] as u64; - } + let value = buffer + .iter() + .take(len) + .fold(0, |value, curr| (value << 8) | *curr as u64); Ok(value) };