Fix array size in insert/remove calls

makes the library easier to consume, also removes the need for the
length check.

also required to build https://github.com/erikh/isync

Signed-off-by: Erik Hollensbe <git@hollensbe.org>
This commit is contained in:
Erik Hollensbe 2022-04-13 02:44:55 -07:00
parent bf297632fb
commit 7223de6fbb
No known key found for this signature in database
GPG key ID: 4BB0E241A863B389

View file

@ -151,16 +151,14 @@ impl<const BUCKETS: usize, const ITEM_BYTES: usize, const HASHES: usize> IBLT<BU
/// Insert a set item into this set.
/// This will panic if the slice is smaller than ITEM_BYTES.
#[inline(always)]
pub fn insert(&mut self, key: &[u8]) {
assert!(key.len() >= ITEM_BYTES);
pub fn insert(&mut self, key: &[u8; ITEM_BYTES]) {
self.ins_rem(unsafe { &*key.as_ptr().cast() }, 1);
}
/// Insert a set item into this set.
/// This will panic if the slice is smaller than ITEM_BYTES.
#[inline(always)]
pub fn remove(&mut self, key: &[u8]) {
assert!(key.len() >= ITEM_BYTES);
pub fn remove(&mut self, key: &[u8; ITEM_BYTES]) {
self.ins_rem(unsafe { &*key.as_ptr().cast() }, -1);
}