summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorClar Charr <clar@charr.xyz>2018-05-15 12:52:16 -0400
committerClar Charr <clar@charr.xyz>2018-05-15 22:24:04 -0400
commit99cf5a92acba672845a3563c4abf98e663eaf5cd (patch)
treed862b55b50e8c8330db487587d921e36598c5682 /src
parentAdd missing Wrapping methods, use doc_comment! (diff)
downloadgrust-99cf5a92acba672845a3563c4abf98e663eaf5cd.tar.gz
grust-99cf5a92acba672845a3563c4abf98e663eaf5cd.tar.bz2
grust-99cf5a92acba672845a3563c4abf98e663eaf5cd.tar.xz
Separate feature gate for wrapping_next_power_of_two
Diffstat (limited to 'src')
-rw-r--r--src/libcore/num/mod.rs5
-rw-r--r--src/libcore/num/wrapping.rs5
2 files changed, 6 insertions, 4 deletions
diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs
index 38f1688f0d..97fcd8ebb5 100644
--- a/src/libcore/num/mod.rs
+++ b/src/libcore/num/mod.rs
@@ -3433,14 +3433,15 @@ the return value is wrapped to `0`.
3433Basic usage: 3433Basic usage:
3434 3434
3435``` 3435```
3436#![feature(wrapping_int_impl)] 3436#![feature(wrapping_next_power_of_two)]
3437", $Feature, " 3437", $Feature, "
3438assert_eq!(2", stringify!($SelfT), ".wrapping_next_power_of_two(), 2); 3438assert_eq!(2", stringify!($SelfT), ".wrapping_next_power_of_two(), 2);
3439assert_eq!(3", stringify!($SelfT), ".wrapping_next_power_of_two(), 4); 3439assert_eq!(3", stringify!($SelfT), ".wrapping_next_power_of_two(), 4);
3440assert_eq!(", stringify!($SelfT), "::max_value().wrapping_next_power_of_two(), 0);", 3440assert_eq!(", stringify!($SelfT), "::max_value().wrapping_next_power_of_two(), 0);",
3441$EndFeature, " 3441$EndFeature, "
3442```"), 3442```"),
3443 #[unstable(feature = "wrapping_int_impl", issue = "32463")] 3443 #[unstable(feature = "wrapping_next_power_of_two", issue = "32463",
3444 reason = "needs decision on wrapping behaviour")]
3444 pub fn wrapping_next_power_of_two(self) -> Self { 3445 pub fn wrapping_next_power_of_two(self) -> Self {
3445 self.one_less_than_next_power_of_two().wrapping_add(1) 3446 self.one_less_than_next_power_of_two().wrapping_add(1)
3446 } 3447 }
diff --git a/src/libcore/num/wrapping.rs b/src/libcore/num/wrapping.rs
index 6d5783282b..d7f87d37f5 100644
--- a/src/libcore/num/wrapping.rs
+++ b/src/libcore/num/wrapping.rs
@@ -874,7 +874,7 @@ When return value overflows (i.e. `self > (1 << (N-1))` for type
874Basic usage: 874Basic usage:
875 875
876``` 876```
877#![feature(wrapping_int_impl)] 877#![feature(wrapping_next_power_of_two)]
878use std::num::Wrapping; 878use std::num::Wrapping;
879 879
880assert_eq!(Wrapping(2", stringify!($t), ").next_power_of_two(), Wrapping(2)); 880assert_eq!(Wrapping(2", stringify!($t), ").next_power_of_two(), Wrapping(2));
@@ -882,7 +882,8 @@ assert_eq!(Wrapping(3", stringify!($t), ").next_power_of_two(), Wrapping(4));
882assert_eq!(Wrapping(200_u8).next_power_of_two(), Wrapping(0)); 882assert_eq!(Wrapping(200_u8).next_power_of_two(), Wrapping(0));
883```"), 883```"),
884 #[inline] 884 #[inline]
885 #[unstable(feature = "wrapping_int_impl", issue = "32463")] 885 #[unstable(feature = "wrapping_next_power_of_two", issue = "32463",
886 reason = "needs decision on wrapping behaviour")]
886 pub fn next_power_of_two(self) -> Self { 887 pub fn next_power_of_two(self) -> Self {
887 Wrapping(self.0.wrapping_next_power_of_two()) 888 Wrapping(self.0.wrapping_next_power_of_two())
888 } 889 }