Fix various clippy lints

This commit is contained in:
Paul Hauner
2019-05-28 10:56:05 +10:00
parent 6e5e1721f7
commit 21ecaddac1
6 changed files with 13 additions and 19 deletions

View File

@@ -102,9 +102,7 @@ impl<'a> SszDecoderBuilder<'a> {
.and_then(|o| Some(o.offset))
.unwrap_or_else(|| BYTES_PER_LENGTH_OFFSET);
if previous_offset > offset {
return Err(DecodeError::OutOfBoundsByte { i: offset });
} else if offset > self.bytes.len() {
if (previous_offset > offset) || (offset > self.bytes.len()) {
return Err(DecodeError::OutOfBoundsByte { i: offset });
}

View File

@@ -54,11 +54,9 @@ impl Decode for bool {
match bytes[0] {
0b0000_0000 => Ok(false),
0b0000_0001 => Ok(true),
_ => {
return Err(DecodeError::BytesInvalid(
format!("Out-of-range for boolean: {}", bytes[0]).to_string(),
))
}
_ => Err(DecodeError::BytesInvalid(
format!("Out-of-range for boolean: {}", bytes[0]).to_string(),
)),
}
}
}
@@ -121,7 +119,7 @@ impl<T: Decode> Decode for Vec<T> {
}
fn from_ssz_bytes(bytes: &[u8]) -> Result<Self, DecodeError> {
if bytes.len() == 0 {
if bytes.is_empty() {
Ok(vec![])
} else if T::is_ssz_fixed_len() {
bytes