-
Notifications
You must be signed in to change notification settings - Fork 30
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
feat: opt-in serialization of sequences as sets #66
Conversation
Before this merges, I do have a method that may allow this to compile down to zero-cost after monomorphization. I'm also considering the value splitting this into 3 modules instead having just one for all three set types and inferring from the first item. Any thoughts? |
8128292
to
37d173e
Compare
This is awesome. Thank you! |
src/set/bytes.rs
Outdated
//! | ||
//! #[derive(Serialize, Deserialize)] | ||
//! struct MyStruct { | ||
//! #[serde(with = "serde_dynamo::set::bytes")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like
#[serde(with = "serde_dynamo::byte_set")]
#[serde(with = "serde_dynamo::number_set")]
#[serde(with = "serde_dynamo::string_set")]
feels a bit better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can made that change; this was mainly just for organization and avoiding a bunch of modules at the crate base. I've been using bytes set (with the plural) since it's a set of byte arrays. If that's okay, I can rename and move these modules into the crate root.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been going off of the naming described here where they're called "number set", "string set" and "binary set".
37d173e
to
37598bb
Compare
For what it's worth, I did once have an implementation of this, but the key bit that was clunky was telling the Serializer that the next stuff is a set. I looked deeply at I also had something with thread locals that was kinda gross. Your newtype struct thing makes a ton of sense and I like it. In the mean time, I noticed that That doesn't preclude this from merging for two reasons:
|
Pull request has been updated to address the above comments on module naming. |
6f093d4
to
d27e12d
Compare
@neoeinstein I have no concerns right now. I just need to find the time to dig in and hopefully merge. Thanks for your contribution! |
feat: opt-in serialization of sequences as sets
Released in 4.2.0, which is now up on crates.io. Thank you! |
I ran into a use case where I'd like to be able to serialize a set of values ergonomically. This relies on the
with
functionality fromserde
to make it completely opt in, enabling this use case without affecting any existing serialization or deserialization.