-
-
Notifications
You must be signed in to change notification settings - Fork 777
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 std::num::NonZero* #1191
Conversation
serde/src/ser/impls.rs
Outdated
where | ||
S: Serializer, | ||
{ | ||
self.clone().get().serialize(serializer) |
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.
Why is this cloned?
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 copied this from the generic NonZero<T>
impl which does not assume T: Copy
(get
takes self
by value), but these concrete types are indeed Copy
so Clone
is not necessary. I’ve removed it.
serde/src/de/impls.rs
Outdated
@@ -1934,6 +1935,39 @@ where | |||
} | |||
} | |||
|
|||
macro_rules! nonzero_integers { | |||
( $( $T: ident, )+ ) => { | |||
nonzero_integers!(@ $(::std::num::$T,)+); |
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.
The @ trick doesn't work on 1.13
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 verified that it does if I swap the order of the macro’s two variants/patterns.
a7ece65
to
f7d0354
Compare
On Travis:
I think this is when running |
The clippy trouble is rust-lang/rust-clippy#2566. |
… gated on the `unstable` Cargo feature. These are new standard library types.
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.
Thanks!
This will enable using serde-rs/serde#1191 in Servo
WIP: Upgrade serde This will enable using serde-rs/serde#1191 in Servo <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/2577) <!-- Reviewable:end -->
WIP: Upgrade serde This will enable using serde-rs/serde#1191 in Servo <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/2577) <!-- Reviewable:end -->
This will enable using serde-rs/serde#1191 in Servo This includes a rebase of serde-rs/serde@master...Gankro:deserialize_from_enums4
Upgrade serde This will enable using serde-rs/serde#1191 in Servo Includes a rebase of serde-rs/serde@master...Gankro:deserialize_from_enums4 <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/2577) <!-- Reviewable:end -->
This will enable using serde-rs/serde#1191 in Servo This includes a rebase of serde-rs/serde@master...Gankro:deserialize_from_enums4
Upgrade serde This will enable using serde-rs/serde#1191 in Servo Includes a rebase of serde-rs/serde@master...Gankro:deserialize_from_enums4 <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/2577) <!-- Reviewable:end -->
… gated on the
unstable
Cargo feature.These are new standard library types. Tracking issue: rust-lang/rust#49137