diff options
| author | Irfan Hudda <irfanhudda@gmail.com> | 2017-05-31 22:25:15 +0530 |
|---|---|---|
| committer | Irfan Hudda <irfanhudda@gmail.com> | 2017-05-31 22:25:15 +0530 |
| commit | 18fadb61c4aab3d1b2fc49ac7d7fea85b3914fb3 (patch) | |
| tree | d3acf81304994c00200002d60d685c2bfc8a16e0 /src/libstd | |
| parent | 93219a262706447c52f3f20819e5caa7b2e2e3a2 (diff) | |
| download | rust-18fadb61c4aab3d1b2fc49ac7d7fea85b3914fb3.tar.gz rust-18fadb61c4aab3d1b2fc49ac7d7fea85b3914fb3.zip | |
Simplify helper functions
Based on @scottmcm 's suggestion
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/num.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/libstd/num.rs b/src/libstd/num.rs index 5f83d077a13..894a6e6796c 100644 --- a/src/libstd/num.rs +++ b/src/libstd/num.rs @@ -176,7 +176,10 @@ mod tests { fn $test_name() { #![test] assert_eq!((0 as $T).checked_next_power_of_two(), Some(1)); - assert!(($T::MAX / 2).checked_next_power_of_two().is_some()); + let smax = $T::MAX >> 1; + assert_eq!(smax.checked_next_power_of_two(), Some(smax+1)); + assert_eq!((smax + 1).checked_next_power_of_two(), Some(smax + 1)); + assert_eq!((smax + 2).checked_next_power_of_two(), None); assert_eq!(($T::MAX - 1).checked_next_power_of_two(), None); assert_eq!($T::MAX.checked_next_power_of_two(), None); let mut next_power = 1; |
