diff --git a/ssz/src/bitfield.rs b/ssz/src/bitfield.rs index 15c9eba..3cf502f 100644 --- a/ssz/src/bitfield.rs +++ b/ssz/src/bitfield.rs @@ -440,7 +440,7 @@ impl Bitfield { /// /// - `bytes` is not the minimal required bytes to represent a bitfield of `bit_len` bits. /// - `bit_len` is not a multiple of 8 and `bytes` contains set bits that are higher than, or - /// equal to `bit_len`. + /// equal to `bit_len`. fn from_raw_bytes(bytes: SmallVec<[u8; SMALLVEC_LEN]>, bit_len: usize) -> Result { if bit_len == 0 { if bytes.len() == 1 && bytes[0] == 0 { @@ -461,7 +461,7 @@ impl Bitfield { }) } else { // Ensure there are no bits higher than `bit_len` that are set to true. - let (mask, _) = u8::max_value().overflowing_shr(8 - (bit_len as u32 % 8)); + let (mask, _) = u8::MAX.overflowing_shr(8 - (bit_len as u32 % 8)); if (bytes.last().expect("Guarded against empty bytes") & !mask) == 0 { Ok(Self { @@ -559,7 +559,7 @@ pub struct BitIter<'a, T> { i: usize, } -impl<'a, T: BitfieldBehaviour> Iterator for BitIter<'a, T> { +impl Iterator for BitIter<'_, T> { type Item = bool; fn next(&mut self) -> Option { @@ -679,7 +679,7 @@ impl arbitrary::Arbitrary<'_> for Bitfield> { let size = N::to_usize(); let mut vec = smallvec![0u8; size]; u.fill_buffer(&mut vec)?; - Ok(Self::from_bytes(vec).map_err(|_| arbitrary::Error::IncorrectFormat)?) + Self::from_bytes(vec).map_err(|_| arbitrary::Error::IncorrectFormat) } } @@ -691,7 +691,7 @@ impl arbitrary::Arbitrary<'_> for Bitfield> { let size = std::cmp::min(rand, max_size); let mut vec = smallvec![0u8; size]; u.fill_buffer(&mut vec)?; - Ok(Self::from_bytes(vec).map_err(|_| arbitrary::Error::IncorrectFormat)?) + Self::from_bytes(vec).map_err(|_| arbitrary::Error::IncorrectFormat) } } diff --git a/ssz/src/decode.rs b/ssz/src/decode.rs index 44a9a88..048f9f0 100644 --- a/ssz/src/decode.rs +++ b/ssz/src/decode.rs @@ -20,7 +20,7 @@ pub enum DecodeError { /// /// - It is `>= bytes.len()`. /// - When decoding variable length items, the 1st offset points "backwards" into the fixed - /// length items (i.e., `length[0] < BYTES_PER_LENGTH_OFFSET`). + /// length items (i.e., `length[0] < BYTES_PER_LENGTH_OFFSET`). /// - When decoding variable-length items, the `n`'th offset was less than the `n-1`'th offset. OutOfBoundsByte { i: usize }, /// An offset points “backwards” into the fixed-bytes portion of the message, essentially @@ -61,11 +61,11 @@ pub enum DecodeError { /// /// - `offset`: the offset bytes (e.g., result of `read_offset(..)`). /// - `previous_offset`: unless this is the first offset in the SSZ object, the value of the -/// previously-read offset. Used to ensure offsets are not decreasing. +/// previously-read offset. Used to ensure offsets are not decreasing. /// - `num_bytes`: the total number of bytes in the SSZ object. Used to ensure the offset is not -/// out of bounds. +/// out of bounds. /// - `num_fixed_bytes`: the number of fixed-bytes in the struct, if it is known. Used to ensure -/// that the first offset doesn't skip any variable bytes. +/// that the first offset doesn't skip any variable bytes. /// /// ## References /// diff --git a/ssz/src/encode/impls.rs b/ssz/src/encode/impls.rs index c1c74d9..245eaa9 100644 --- a/ssz/src/encode/impls.rs +++ b/ssz/src/encode/impls.rs @@ -251,7 +251,7 @@ impl Encode for Arc { } // Encode transparently through references. -impl<'a, T: Encode> Encode for &'a T { +impl Encode for &T { fn is_ssz_fixed_len() -> bool { T::is_ssz_fixed_len() } diff --git a/ssz/src/legacy.rs b/ssz/src/legacy.rs index 4953db0..5cce666 100644 --- a/ssz/src/legacy.rs +++ b/ssz/src/legacy.rs @@ -239,9 +239,9 @@ mod test { (0, 0), (0, 1), (1, 0), - (u8::max_value(), u16::max_value()), - (0, u16::max_value()), - (u8::max_value(), 0), + (u8::MAX, u16::MAX), + (0, u16::MAX), + (u8::MAX, 0), (42, 12301), ]; diff --git a/ssz/src/lib.rs b/ssz/src/lib.rs index 66b16de..edb91a3 100644 --- a/ssz/src/lib.rs +++ b/ssz/src/lib.rs @@ -53,9 +53,9 @@ pub use union_selector::UnionSelector; pub const BYTES_PER_LENGTH_OFFSET: usize = 4; /// The maximum value that can be represented using `BYTES_PER_LENGTH_OFFSET`. #[cfg(target_pointer_width = "32")] -pub const MAX_LENGTH_VALUE: usize = (std::u32::MAX >> (8 * (4 - BYTES_PER_LENGTH_OFFSET))) as usize; +pub const MAX_LENGTH_VALUE: usize = (u32::MAX >> (8 * (4 - BYTES_PER_LENGTH_OFFSET))) as usize; #[cfg(target_pointer_width = "64")] -pub const MAX_LENGTH_VALUE: usize = (std::u64::MAX >> (8 * (8 - BYTES_PER_LENGTH_OFFSET))) as usize; +pub const MAX_LENGTH_VALUE: usize = (u64::MAX >> (8 * (8 - BYTES_PER_LENGTH_OFFSET))) as usize; /// The number of bytes used to indicate the variant of a union. pub const BYTES_PER_UNION_SELECTOR: usize = 1; diff --git a/ssz/tests/tests.rs b/ssz/tests/tests.rs index 139ad39..4d4262b 100644 --- a/ssz/tests/tests.rs +++ b/ssz/tests/tests.rs @@ -147,7 +147,7 @@ mod round_trip { FixedLen { a: 1, b: 0, c: 1 }, ]; - let expected_encodings = vec![ + let expected_encodings = [ // | u16--| u64----------------------------| u32----------| vec![00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00], vec![01, 00, 01, 00, 00, 00, 00, 00, 00, 00, 01, 00, 00, 00], @@ -265,7 +265,7 @@ mod round_trip { }, ]; - let expected_encodings = vec![ + let expected_encodings = [ // 00..................................09 // | u16--| vec offset-----| u32------------| vec payload --------| vec![00, 00, 10, 00, 00, 00, 00, 00, 00, 00], @@ -354,9 +354,9 @@ mod round_trip { (0, 0), (0, 1), (1, 0), - (u8::max_value(), u16::max_value()), - (0, u16::max_value()), - (u8::max_value(), 0), + (u8::MAX, u16::MAX), + (0, u16::MAX), + (u8::MAX, 0), (42, 12301), ];