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/Deserialize for std::num::Saturating<T> #2708

Closed
jbethune opened this issue Mar 3, 2024 · 1 comment · Fixed by #2709
Closed

Impl Serialize/Deserialize for std::num::Saturating<T> #2708

jbethune opened this issue Mar 3, 2024 · 1 comment · Fixed by #2709

Comments

@jbethune
Copy link

jbethune commented Mar 3, 2024

It would be nice if we could get

use std::num::Saturating;

impl Deserialize for Saturating<T: Deserialize> { ... }
impl Serialize for Saturating<T: Serialize> { ... }

so that it is possible to handle wrapped types, that already support those traits.

@jbethune
Copy link
Author

jbethune commented Mar 3, 2024

Edit: I mixed up Wrapping and Saturating. However, I still want to link to the implementations for Serialize and Deserialize for Wrapping<T>, because the future implementations for Saturating<T> will probably be very similar.

@jbethune jbethune closed this as completed Mar 3, 2024
@jbethune jbethune reopened this Mar 4, 2024
jbethune pushed a commit to jbethune/serde that referenced this issue Mar 4, 2024
This implementation is heavily inspired by the existing trait
implentation for `std::num::Wrapping<T>`.

fix serde-rs#2708
jbethune pushed a commit to jbethune/serde that referenced this issue Mar 27, 2024
This implementation is heavily inspired by the existing trait
implentation for `std::num::Wrapping<T>`.

fix serde-rs#2708
jbethune pushed a commit to jbethune/serde that referenced this issue Mar 27, 2024
This implementation is heavily inspired by the existing trait
implentation for `std::num::Wrapping<T>`.

fix serde-rs#2708
jbethune pushed a commit to jbethune/serde that referenced this issue Apr 5, 2024
The serialization implementation is heavily
inspired by the existing trait implentation for
`std::num::Wrapping<T>`.

The deserializing implementation maps input values
that lie outside of the numerical range of the
output type to the `MIN` or `MAX` value of the
output type, depending on the sign of the input
value. This behaviour follows to the `Saturating`
semantics of the output type.

fix serde-rs#2708
jbethune pushed a commit to jbethune/serde that referenced this issue Apr 6, 2024
The serialization implementation is heavily
inspired by the existing trait implentation for
`std::num::Wrapping<T>`.

The deserializing implementation maps input values
that lie outside of the numerical range of the
output type to the `MIN` or `MAX` value of the
output type, depending on the sign of the input
value. This behaviour follows to the `Saturating`
semantics of the output type.

fix serde-rs#2708
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant