From 0cab98ffe161108ad63d25f6308451c636e2585a Mon Sep 17 00:00:00 2001 From: Grant Wuerker Date: Sat, 20 Oct 2018 18:43:43 -0500 Subject: [PATCH] another loop fixed --- beacon_chain/utils/ssz/src/decode.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/beacon_chain/utils/ssz/src/decode.rs b/beacon_chain/utils/ssz/src/decode.rs index 3d81b70ba..53f82547c 100644 --- a/beacon_chain/utils/ssz/src/decode.rs +++ b/beacon_chain/utils/ssz/src/decode.rs @@ -1,5 +1,3 @@ -#![cfg_attr(not(feature = "clippy"), allow(needless_range_loop))] - use super::{ LENGTH_BYTES, }; @@ -79,10 +77,10 @@ pub fn decode_length(bytes: &[u8], index: usize, length_bytes: usize) return Err(DecodeError::TooShort); }; let mut len: usize = 0; - for i in index..index+length_bytes { + for (i, byte) in bytes.iter().enumerate().take(index+length_bytes).skip(index) { let offset = (index+length_bytes - i - 1) * 8; - len |= (bytes[i] as usize) << offset; - }; + len |= (*byte as usize) << offset; + } Ok(len) }