[][src]Function bit_mask_ring_buf::next_pow_of_2

pub fn next_pow_of_2(n: usize) -> usize

Returns the next highest power of 2 if n is not already a power of 2. This will return 2 if n < 2.

Example

use bit_mask_ring_buf::next_pow_of_2;

assert_eq!(next_pow_of_2(3), 4);
assert_eq!(next_pow_of_2(8), 8);
assert_eq!(next_pow_of_2(0), 2);

Panics

  • This will panic if n > (std::usize::MAX/2)+1