suppressed unknown lint warning in test

This commit is contained in:
Grant Wuerker 2018-10-23 19:34:47 -05:00
parent d670294c11
commit 4c272d7f0a
2 changed files with 7 additions and 5 deletions

View File

@ -1,3 +1,5 @@
#![allow(unknown_lints)]
use super::{ use super::{
LENGTH_BYTES LENGTH_BYTES
}; };

View File

@ -8,18 +8,18 @@ use super::{
macro_rules! impl_decodable_for_uint { macro_rules! impl_decodable_for_uint {
($type: ident, $bit_size: expr) => { ($type: ident, $bit_size: expr) => {
impl Decodable for $type { impl Decodable for $type {
fn ssz_decode(bytes: &[u8], start_bytes: usize) fn ssz_decode(bytes: &[u8], index: usize)
-> Result<(Self, usize), DecodeError> -> Result<(Self, usize), DecodeError>
{ {
assert!((0 < $bit_size) & assert!((0 < $bit_size) &
($bit_size <= 64) & ($bit_size <= 64) &
($bit_size % 8 == 0)); ($bit_size % 8 == 0));
let max_bytes = $bit_size / 8; let max_bytes = $bit_size / 8;
if bytes.len() >= (start_bytes + max_bytes) { if bytes.len() >= (index + max_bytes) {
let end_bytes = start_bytes + max_bytes; let end_bytes = index + max_bytes;
let mut result: $type = 0; let mut result: $type = 0;
for (index, byte) in bytes.iter().enumerate().take(end_bytes).skip(start_bytes) { for (i, byte) in bytes.iter().enumerate().take(end_bytes).skip(index) {
let offset = (end_bytes - index - 1) * 8; let offset = (end_bytes - i - 1) * 8;
result |= ($type::from(*byte)) << offset; result |= ($type::from(*byte)) << offset;
} }
Ok((result, end_bytes)) Ok((result, end_bytes))