diff options
| author | Irfan Hudda <irfanhudda@gmail.com> | 2017-04-29 01:51:54 +0530 |
|---|---|---|
| committer | Irfan Hudda <irfanhudda@gmail.com> | 2017-04-29 01:51:54 +0530 |
| commit | ed24829985cd01ae7ab980d785b6dff2e8332868 (patch) | |
| tree | 51a110d2e411d4a5ef9ca3fabf5648b1a2acdcde | |
| parent | 67684a399c2020495075b2e6c848850e7a8d60e9 (diff) | |
| download | rust-ed24829985cd01ae7ab980d785b6dff2e8332868.tar.gz rust-ed24829985cd01ae7ab980d785b6dff2e8332868.zip | |
Simplify `checked_next_power_of_two` function
| -rw-r--r-- | src/libcore/num/mod.rs | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 8c4a6e871e1..cc1f9ca79a1 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -2376,12 +2376,7 @@ macro_rules! uint_impl { /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn checked_next_power_of_two(self) -> Option<Self> { - let npot = self.one_less_than_next_power_of_two().wrapping_add(1); - if npot >= self { - Some(npot) - } else { - None - } + self.one_less_than_next_power_of_two().checked_add(1) } } } |
