ayazhafiz / xorf

Xor filters - efficient probabilistic hashsets. Faster and smaller than bloom and cuckoo filters.
MIT License
129 stars 27 forks source link

`BinaryFuse` filters only implement `TryFrom`, conflicting with `HashProxy` #72

Open ghost opened 1 year ago

ghost commented 1 year ago

Attempting to use a HashProxy<String, DefaultHasher, BinaryFuse8> is impossible in the current state due to HashProxy::from failing. You can reproduce by replacing Xor8 with BinaryFuse8 in the example.

Output from cargo:

error[E0277]: the trait bound `xorf::BinaryFuse8: std::convert::From<std::vec::Vec<u64>>` is not satisfied
  --> src\lib.rs:59:84
   |
59 |     let pw_filter: HashProxy<String, DefaultHasher, BinaryFuse8> = HashProxy::from(&passwords);
   |                                                                    --------------- ^^^^^^^^^^ the trait `std::convert::From<std::vec::Vec<u64>>` is not implemented for `xorf::BinaryFuse8`
   |                                                                    |
   |                                                                    required by a bound introduced by this call
   |
   = help: the following other types implement trait `std::convert::From<T>`:
             <xorf::HashProxy<T, H, F> as std::convert::From<&[T]>>
             <xorf::HashProxy<T, H, F> as std::convert::From<&std::vec::Vec<T>>>
   = note: required for `xorf::HashProxy<std::string::String, std::collections::hash_map::DefaultHasher, xorf::BinaryFuse8>` to implement `std::convert::From<&std::vec::Vec<std::string::String>>`
ayazhafiz commented 1 year ago

We should probably have HashProxy implement TryFrom in this case. Would that work for your use case?

ghost commented 1 year ago

I do believe it would, yes! For reference, I learned more and have since moved away from HashProxy for my use case, however, this would still be good for newcomers.