Skip to content
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

impl Serialize and Deserialize for core::cmp::Reverse #1486

Merged
merged 2 commits into from Mar 1, 2019
Merged

impl Serialize and Deserialize for core::cmp::Reverse #1486

merged 2 commits into from Mar 1, 2019

Conversation

vorot93
Copy link
Contributor

@vorot93 vorot93 commented Feb 20, 2019

No description provided.

@dtolnay
Copy link
Member

dtolnay commented Feb 20, 2019

Is it possible to share your code that would need to use these impls? I have not come across Reverse<T> needing to be serialized.

@vorot93
Copy link
Contributor Author

vorot93 commented Feb 20, 2019

I see it as a very convenient way to serialize a sorted collection in the reverse order. Like this:

let mut my_coll = BTreeSet::new();
my_coll.insert(Reverse(1));
my_coll.insert(Reverse(2));
my_coll.insert(Reverse(3));

assert_eq!(serde_json::to_string(&my_coll).unwrap(), "[3, 2, 1]");

@dtolnay
Copy link
Member

dtolnay commented Feb 20, 2019

Thanks, that's fair. You will need to add a build flag in build.rs because core::cmp::Reverse is new in 1.19.0 and we support back to 1.13.0.

@vorot93
Copy link
Contributor Author

vorot93 commented Feb 20, 2019

@dtolnay Done.

Copy link
Member

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@dtolnay dtolnay merged commit 97920be into serde-rs:master Mar 1, 2019
@dtolnay
Copy link
Member

dtolnay commented Mar 1, 2019

Released in 1.0.89.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants