diff -r aef7eb135a0c -r 0d19b7de6f5d src/vrrpv2.rs --- a/src/vrrpv2.rs Tue Jan 03 20:35:05 2023 +0530 +++ b/src/vrrpv2.rs Wed Jan 04 15:58:49 2023 +0530 @@ -77,6 +77,13 @@ })(input) } +// Nightly has a nicer array_chunks API to express it more succinctly. +// let mut chunks = bytes.array_chunks(2); +// let mut sum = chunks.map(u16::from_ne_bytes).map(|b| b as u32).sum::(); +// // handle the remainder +// if let Some([b]) = chunks.remainder() { +// sum += *b as u32 +// } fn validate_checksum(bytes: &[u8]) -> bool { let mut sum: u32 = bytes.chunks(2).fold(0, |acc: u32, x| { acc + u32::from(u16::from_ne_bytes(x.try_into().unwrap()))