-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add impls for &Wrapping
. Also Sum
, Product
impls for both Wrapping
and &Wrapping
.
#37356
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
Looks good to me. |
Sum
and Product
impls for Wrapping
&Wrapping
. Also Sum
, Product
impls for both Wrapping
and &Wrapping
.
|
||
// implements the unary operator "op &T" | ||
// based on "op T" where T is expected to be `Copy`able | ||
macro_rules! forward_ref_unop { |
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.
These are moved from std::ops
so that they can be shared for the Wrapping
implementations.
} | ||
} | ||
|
||
#[stable(feature = "iter_arith_traits", since = "1.12.0")] | ||
impl<'a> Product<&'a $a> for $a { | ||
fn product<I: Iterator<Item=&'a $a>>(iter: I) -> $a { | ||
iter.cloned().fold(1, Mul::mul) |
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 cloned
stuff is not necessary (and wasn't before) since Add::add
etc are implemented for references of primitives (as well as, now, Wrapping
).
@bluss I added a different commit to implement ops on (I can split this into two PRs, but I thought getting rid of the |
@rfcbot fcp merge Looks good to me! |
Team member @alexcrichton has proposed to merge this. The next step is review by the rest of the tagged teams: No concerns currently listed. Once these reviewers reach consensus, this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
🔔 This is now entering its final comment period, as per the review above. 🔔 psst @alexcrichton, I wasn't able to add the |
@bors: r+ |
📌 Commit df0e5a9 has been approved by |
Add impls for `&Wrapping`. Also `Sum`, `Product` impls for both `Wrapping` and `&Wrapping`. There are two changes here (split into two commits): - Ops for references to `&Wrapping` (`Add`, `Sub`, `Mul` etc.) similar to the way they are implemented for primitives. - Impls for `iter::{Sum,Product}` for `Wrapping`. As far as I know `impl` stability attributes don't really matter so I didn't bother breaking up the macro for two different kinds of stability. Happy to change if it does matter.
Add impls for `&Wrapping`. Also `Sum`, `Product` impls for both `Wrapping` and `&Wrapping`. There are two changes here (split into two commits): - Ops for references to `&Wrapping` (`Add`, `Sub`, `Mul` etc.) similar to the way they are implemented for primitives. - Impls for `iter::{Sum,Product}` for `Wrapping`. As far as I know `impl` stability attributes don't really matter so I didn't bother breaking up the macro for two different kinds of stability. Happy to change if it does matter.
There are two changes here (split into two commits):
&Wrapping
(Add
,Sub
,Mul
etc.) similar to the way they are implemented for primitives.iter::{Sum,Product}
forWrapping
.As far as I know
impl
stability attributes don't really matter so I didn't bother breaking up the macro for two different kinds of stability. Happy to change if it does matter.