Skip to content

Commit

Permalink
Separate feature gate for wrapping_next_power_of_two
Browse files Browse the repository at this point in the history
  • Loading branch information
clarfonthey committed May 16, 2018
1 parent a00e68d commit 99cf5a9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/libcore/num/mod.rs
Expand Up @@ -3433,14 +3433,15 @@ the return value is wrapped to `0`.
Basic usage:
```
#![feature(wrapping_int_impl)]
#![feature(wrapping_next_power_of_two)]
", $Feature, "
assert_eq!(2", stringify!($SelfT), ".wrapping_next_power_of_two(), 2);
assert_eq!(3", stringify!($SelfT), ".wrapping_next_power_of_two(), 4);
assert_eq!(", stringify!($SelfT), "::max_value().wrapping_next_power_of_two(), 0);",
$EndFeature, "
```"),
#[unstable(feature = "wrapping_int_impl", issue = "32463")]
#[unstable(feature = "wrapping_next_power_of_two", issue = "32463",
reason = "needs decision on wrapping behaviour")]
pub fn wrapping_next_power_of_two(self) -> Self {
self.one_less_than_next_power_of_two().wrapping_add(1)
}
Expand Down
5 changes: 3 additions & 2 deletions src/libcore/num/wrapping.rs
Expand Up @@ -874,15 +874,16 @@ When return value overflows (i.e. `self > (1 << (N-1))` for type
Basic usage:
```
#![feature(wrapping_int_impl)]
#![feature(wrapping_next_power_of_two)]
use std::num::Wrapping;
assert_eq!(Wrapping(2", stringify!($t), ").next_power_of_two(), Wrapping(2));
assert_eq!(Wrapping(3", stringify!($t), ").next_power_of_two(), Wrapping(4));
assert_eq!(Wrapping(200_u8).next_power_of_two(), Wrapping(0));
```"),
#[inline]
#[unstable(feature = "wrapping_int_impl", issue = "32463")]
#[unstable(feature = "wrapping_next_power_of_two", issue = "32463",
reason = "needs decision on wrapping behaviour")]
pub fn next_power_of_two(self) -> Self {
Wrapping(self.0.wrapping_next_power_of_two())
}
Expand Down

0 comments on commit 99cf5a9

Please sign in to comment.