diff --git a/iblt/src/lib.rs b/iblt/src/lib.rs index 8b95de9e4..7fda2055b 100644 --- a/iblt/src/lib.rs +++ b/iblt/src/lib.rs @@ -19,17 +19,17 @@ fn xor_with(x: &mut [u8; L], y: &[u8; L]) { fn xor_with(x: &mut [u8; L], y: &[u8; L]) { if L >= 16 { for i in 0..(L / 16) { - unsafe { *x.as_mut_ptr().cast::().add(i) ^= *y.as_ptr().cast::() }; + unsafe { *x.as_mut_ptr().cast::().add(i) ^= *y.as_ptr().cast::().add(i) }; } for i in (L - (L % 16))..L { - unsafe { *x.as_mut_ptr().cast::().add(i) ^= *y.as_ptr().cast::() }; + unsafe { *x.as_mut_ptr().add(i) ^= *y.as_ptr().add(i) }; } } else { for i in 0..(L / 8) { - unsafe { *x.as_mut_ptr().cast::().add(i) ^= *y.as_ptr().cast::() }; + unsafe { *x.as_mut_ptr().cast::().add(i) ^= *y.as_ptr().cast::().add(i) }; } for i in (L - (L % 8))..L { - unsafe { *x.as_mut_ptr().cast::().add(i) ^= *y.as_ptr().cast::() }; + unsafe { *x.as_mut_ptr().add(i) ^= *y.as_ptr().add(i) }; } } } @@ -210,9 +210,9 @@ impl IBLT BUCKETS { // sanity check, should be impossible @@ -226,10 +226,19 @@ impl IBLT PartialEq for IBLT { + #[inline(always)] + fn eq(&self, other: &Self) -> bool { + self.as_bytes().eq(other.as_bytes()) + } +} + +impl Eq for IBLT {} + #[cfg(test)] mod tests { #[inline(always)]