jedisct1 / rust-bloom-filter

A fast Bloom filter implementation in Rust
BSD 2-Clause "Simplified" License
235 stars 51 forks source link

Move rand crate behind feature gate #28

Closed jhwgh1968 closed 3 years ago

jhwgh1968 commented 3 years ago

This PR places the crate's requirement on the rand behind a feature gate, so that it can be supported on bare-metal embedded and WebAssembly platforms. (Random generation is of course enabled by default.)

To achieve this, it adds two functions to create SIP hashers with provided initial state, rather than randomly generating it.

jedisct1 commented 3 years ago

Hi, and thank you!

The with_init prefix is a bit counterintuitive, considering the fact that regular functions use the new prefix.

Maybe new_with_seed() and new_for_fp_rate_with_seed()?

Also instead of accepting two u64, which is the internal representation, but not very convenient, maybe accept 16 bytes and decode them as little endian? That would be easier from a user perspective.

jhwgh1968 commented 3 years ago

Just as an explanation, I thought new and with_init was logical based on Vec's new and with_capacity. But I suppose "init" is less descriptive in retrospect.

Still, your version looks good. Thanks!