mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-16 21:15:18 +03:00
Separate feature gate for wrapping_next_power_of_two
This commit is contained in:
@@ -3433,14 +3433,15 @@ pub fn checked_next_power_of_two(self) -> Option<Self> {
|
||||
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)
|
||||
}
|
||||
|
||||
@@ -874,7 +874,7 @@ pub fn is_power_of_two(self) -> bool {
|
||||
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));
|
||||
@@ -882,7 +882,8 @@ pub fn is_power_of_two(self) -> bool {
|
||||
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())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user