Skip to main content

checked_next_power_of_two

Function checked_next_power_of_two 

Source
pub fn checked_next_power_of_two(n: usize) -> Option<usize>
Expand description

Smallest power of two greater than or equal to n, or None on overflow.

n == 0 maps to 1. Inputs above usize::MAX / 2 + 1 have no representable answer and yield None instead of silently wrapping to zero.