DoumanAsh / xxhash-rust

Rust implementation of xxhash
Boost Software License 1.0
205 stars 20 forks source link

would it be nice to add Default? #23

Closed BrianHicks closed 2 years ago

BrianHicks commented 2 years ago

I have a program that, simplified, that looks something like this:

let mut some_map: HashMap<String, HashSet<String>, Xxh3Builder> = HashMap::with_hasher(Xxh3Builder::new());

// ...

let entry = some_map.entry(some_string);
entry.or_default().insert(some_other_string);

I realized I could use HashSet<String, Xxh3Builder> in the values here, but the code fails to compile, since Xxh3Builder does not implement Default. Would that be desirable?

(Of course this is not too hard to fix in my code, but it'd also be nice to not have to!)

DoumanAsh commented 2 years ago

Hmm, I'm not sure I follow? I think HashMap has only with_hasher method to created map with custom hasher?

DoumanAsh commented 2 years ago

Well, in any case I added Default and published it as 0.8.6

BrianHicks commented 2 years ago

Thank you!

To clarify, I’m talking about the or_default call that creates the set, not the call that creates the dict. This will make life easier, though, so thanks!