jedisct1 / rust-bloom-filter

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

Cleaner syntax for `compute_bitmap_size`. #24

Closed neoneye closed 3 years ago

neoneye commented 3 years ago

It works when using this syntax let bitmap_size: usize = Bloom::<()>::compute_bitmap_size(1000, 0.1);. However the syntax took me several attempts to get right.

A more intuitive syntax could be something like this

let bitmap_size: usize = Bloom::compute_bitmap_size(1000, 0.1);

However this doesn't compile

type annotations needed

cannot infer type for type parameter `T` declared on the struct `Bloom`rustc(E0282)
bloom_experiments.rs(26, 34): cannot infer type for type parameter `T` declared on the struct `Bloom`
jedisct1 commented 3 years ago

This is the joy of Rust. Unnecessarily verbose syntax justified as a way to be explicit, and sigils to make the code look like it's reserved to connoisseurs.

::<()> works but the expected type here is the index type.