--- a/src/vrrpv2.rs Wed Jan 04 15:58:49 2023 +0530
+++ b/src/vrrpv2.rs Thu Jan 05 16:03:05 2023 +0530
@@ -84,6 +84,12 @@
// if let Some([b]) = chunks.remainder() {
// sum += *b as u32
// }
+
+// Shadowing can be used to avoid `mut`...
+// let sum =...;
+// let sum = (sum & 0xffff) + (sum >> 16);
+// let sum = (sum & 0xffff) + (sum >> 16);
+// manually un-rolling while loop since it's needed atmost twice for an 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()))