Skip to content

Commit ed24829

Browse files
committed
Simplify checked_next_power_of_two function
1 parent 67684a3 commit ed24829

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

src/libcore/num/mod.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2376,12 +2376,7 @@ macro_rules! uint_impl {
23762376
/// ```
23772377
#[stable(feature = "rust1", since = "1.0.0")]
23782378
pub fn checked_next_power_of_two(self) -> Option<Self> {
2379-
let npot = self.one_less_than_next_power_of_two().wrapping_add(1);
2380-
if npot >= self {
2381-
Some(npot)
2382-
} else {
2383-
None
2384-
}
2379+
self.one_less_than_next_power_of_two().checked_add(1)
23852380
}
23862381
}
23872382
}

0 commit comments

Comments
 (0)