Uh oh!
There was an error while loading. Please reload this page.
Implement Integer methods for Wrapping - #48810
Conversation
rust-highfive
commented
Mar 7, 2018
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @BurntSushi (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
Phlosioneer
commented
Mar 7, 2018
| #[inline] | ||
| #[unstable(feature = "wrapping_int_impl", issue = "32463")] | ||
| pub fn pow(self, exp: u32) -> Self { | ||
| Wrapping(self.0.pow(exp)) |
There was a problem hiding this comment.
I think this one should call wrapping_pow? And maybe include a doctest demonstrating that it wraps...
There was a problem hiding this comment.
I wanted to name it pow to mirror the names on u8 etc. These impls are intended to make generic code that operates on integer types work seamlessly with wrapping integer types, and that requires the method names to be the same.
I'll add a wrapping example to the doctest.
There was a problem hiding this comment.
I think @scottmcm meant that within, it should call self.0.wrapping_pow(exp). Otherwise, it might actually overflow / panic.
| } | ||
There was a problem hiding this comment.
[00:06:04] tidy error: /checkout/src/libcore/num/wrapping.rs:528: trailing whitespace
[00:06:04] tidy error: /checkout/src/libcore/num/wrapping.rs: too many trailing newlines (4)
afb1870 to
02aa39fComparedtolnay
commented
Mar 10, 2018
@bors r+ |
bors
commented
Mar 10, 2018
📌 Commit 910d855 has been approved by |
…wrapping, r=dtolnay Implement Integer methods for Wrapping Wrapping<T> now implements: count_ones, count_zeros, leading_zeros, trailing_zeros, rotate_left, rotate_right, swap_bytes, from_be, from_le, to_be, to_le, and pow where T is: u8, u16, u32, u64, usize, i8, i16, i32, i64, or isize. Docs were written for all these methods, as well as examples. The examples mirror the ones on u8, u16, etc... for consistency. Closesrust-lang#32463
kennytm
commented
Mar 11, 2018
@bors rollup |
…wrapping, r=dtolnay Implement Integer methods for Wrapping Wrapping<T> now implements: count_ones, count_zeros, leading_zeros, trailing_zeros, rotate_left, rotate_right, swap_bytes, from_be, from_le, to_be, to_le, and pow where T is: u8, u16, u32, u64, usize, i8, i16, i32, i64, or isize. Docs were written for all these methods, as well as examples. The examples mirror the ones on u8, u16, etc... for consistency. Closesrust-lang#32463
kennytm
commented
Mar 13, 2018
@bors rollup- |
bors
commented
Mar 14, 2018
⌛ Testing commit 910d855 with merge 2b0dbffed5e11b4b565e4011d77ccf12493bd82b... |
bors
commented
Mar 14, 2018
💔 Test failed - status-travis |
Phlosioneer
commented
Mar 14, 2018
Is there something wrong with my PR...? A rollup error log doesn't usually show up directly under a PR. The error is weird, though... something about duplicate rustdoc for |
scottmcm
commented
Mar 14, 2018
@Phlosioneer It was removed from the rollup, see #48810 (comment) (I don't understand the error either.) |
uhm, what do I need to do? I don't think this is |
kennytm
commented
Mar 16, 2018
@Phlosioneer Try to change (cc @GuillaumeGomez about the order change on i686.) |
SimonSapin
commented
Mar 17, 2018
I’ve filed #49123 for that rustdoc test failure. |
Wrapping<T> now implements: count_ones, count_zeros, leading_zeros, trailing_zeros, rotate_left, rotate_right, swap_bytes, from_be, from_le, to_be, to_le, and pow where T is: u8, u16, u32, u64, usize, i8, i16, i32, i64, or isize. Docs were written for all these methods, as well as examples. The examples mirror the ones on u8, u16, etc... for consistency. Closesrust-lang#32463
910d855 to
bf101a5ComparePhlosioneer
commented
Mar 19, 2018
I rebased against master, and I don't see #49123 during local testing. We'll see if travis agrees. |
GuillaumeGomez
commented
Mar 19, 2018
I have no idea why there is a change in the order... If there is a problem, I think it comes from the internals of rust instead of rustdoc. |
kennytm
commented
Mar 19, 2018
@bors r=dtolnay Let's try again then. |
bors
commented
Mar 19, 2018
📌 Commit bf101a5 has been approved by |
…wrapping, r=dtolnay Implement Integer methods for Wrapping Wrapping<T> now implements: count_ones, count_zeros, leading_zeros, trailing_zeros, rotate_left, rotate_right, swap_bytes, from_be, from_le, to_be, to_le, and pow where T is: u8, u16, u32, u64, usize, i8, i16, i32, i64, or isize. Docs were written for all these methods, as well as examples. The examples mirror the ones on u8, u16, etc... for consistency. Closesrust-lang#32463
kennytm
commented
Mar 20, 2018
@bors rollup |
Wrapping now implements:
count_ones, count_zeros, leading_zeros,
trailing_zeros, rotate_left, rotate_right, swap_bytes, from_be,
from_le, to_be, to_le, and pow
where T is:
u8, u16, u32, u64, usize, i8, i16, i32, i64, or isize.
Docs were written for all these methods, as well as examples. The
examples mirror the ones on u8, u16, etc... for consistency.
Closes#32463