rust-cuckoofilter
rust-cuckoofilter copied to clipboard
`impl<'a> From<&'a [u8]> for Bucket` doesn't adhere Rust conventions
The following code is problematic:
https://github.com/seiflotfy/rust-cuckoofilter/blob/c7fea791f1c21deda02a263e69f0fec428e10c61/src/bucket.rs#L96-L105
This code can panic for two reasons: 1) fingerprints
contains more than BUCKET_SIZE
chunks; 2) fingerprints
can't be divided evenly into FINGERPRINT_SIZE
d chunks (slice_copy
forwards to [T]::copy_from_slice
which panics if slices have different lengths). However, the documentation for From
trait explicitly claims that conversions defined through From::from
should be infallible.
The correct solution in this case would be redo this code into TryFrom
impl. Of course, this would break backwards compatibility.