-
Notifications
You must be signed in to change notification settings - Fork 298
serde support #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Nevermind, |
14: Add Serde support r=Amanieu a=hcpl The code is taken as is from upstream Serde impls for `std::collections::{HashMap, HashSet}` barring few syntactic sugar changes. Closes https://github.com/Amanieu/hashbrown/issues/6. Co-authored-by: hcpl <[email protected]>
#14 was merged before the 0.1.5 release, but I still can't error[E0277]: the trait bound `hashbrown::HashMap<T, T>: serde::Deserialize<'_>` is not satisfied
--> src/main.rs:32:10
|
32 | #[derive(Deserialize)]
| ^^^^^^^^^^^ the trait `serde::Deserialize<'_>` is not implemented for `hashbrown::HashMap<T, T>`
|
= note: required by `serde::de::SeqAccess::next_element`
error[E0277]: the trait bound `hashbrown::HashMap<T, T>: serde::Deserialize<'_>` is not satisfied
--> src/main.rs:32:10
|
32 | #[derive(Deserialize)]
| ^^^^^^^^^^^ the trait `serde::Deserialize<'_>` is not implemented for `hashbrown::HashMap<T, T>`
|
= note: required by `serde::de::MapAccess::next_value` |
@clbarnes sorry for a very late response, but if your issue hasn't been resolved yet, could you please share code that produces these errors?
The |
Sure thing! https://github.com/clbarnes/hash_test/tree/master As the readme says, that repo is in a state which builds and runs (demonstrating that std, fx and fnv all work); uncomment L51 on Can't wait to use this library as soon as I can get the deserializing to work (my application is a port from JS and very lookup-heavy, hashbrown gives a 2x speedup over fx); thanks very much for your work. |
Oh, Serde support was made optional for hashbrown to reduce compile times for those who don't need it. So to make your code compile, just replace hashbrown = "0.1.6" with hashbrown = { version = "0.1.6", features = ["serde"] } The reason why Serde support worked for other cases is thanks to the combination of distinct factors:
Hope the explanation is able to clear your confusion! |
Got it, didn't think about the feature flag. Thanks! |
A feature that enables these
Hash{Map,Set}
s to be used with serde (likestd::collections
) would be awesome.The text was updated successfully, but these errors were encountered: