diff options
author | Sunil Nimmagadda <sunil@nimmagadda.net> | 2023-01-04 15:58:49 +0530 |
---|---|---|
committer | Sunil Nimmagadda <sunil@nimmagadda.net> | 2023-01-04 15:58:49 +0530 |
commit | 70e972a8bebfd5cb6ca9d7c7517a8fa007e12267 (patch) | |
tree | 4ee0a3c90bef41643a45e6633bf0e0ccb0aa9b08 /src | |
parent | 73c575e10600991d85b7b3caf669972db46a2f54 (diff) |
Leave a note of a nightly feature feedback received on discord.
Diffstat (limited to 'src')
-rw-r--r-- | src/vrrpv2.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/vrrpv2.rs b/src/vrrpv2.rs index 77198e9..0db2d7d 100644 --- a/src/vrrpv2.rs +++ b/src/vrrpv2.rs @@ -77,6 +77,13 @@ fn parse_auth_type(input: &[u8]) -> IResult<&[u8], VRRPv2AuthType> { })(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::<u32>(); +// // 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())) |