pub trait NextPowerOf2Assign {
    // Required method
    fn next_power_of_2_assign(&mut self);
}
Expand description

Replaces a number with the smallest power of 2 greater than or equal it. Assumes the result is representable.

Required Methods§

Implementations on Foreign Types§

source§

impl NextPowerOf2Assign for f32

source§

fn next_power_of_2_assign(&mut self)

Replaces a number with the smallest power of 2 greater than or equal to it.

$x \gets 2^{\lceil \log_2 x \rceil}$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if the next power of 2 is greater than the type’s maximum value.

§Examples

See here.

source§

impl NextPowerOf2Assign for f64

source§

fn next_power_of_2_assign(&mut self)

Replaces a number with the smallest power of 2 greater than or equal to it.

$x \gets 2^{\lceil \log_2 x \rceil}$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if the next power of 2 is greater than the type’s maximum value.

§Examples

See here.

source§

impl NextPowerOf2Assign for u8

source§

fn next_power_of_2_assign(&mut self)

Replaces a number with the smallest power of 2 greater than or equal to it.

$x \gets 2^{\lceil \log_2 x \rceil}$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if the next power of 2 is greater than the type’s maximum value.

§Examples

See here.

source§

impl NextPowerOf2Assign for u16

source§

fn next_power_of_2_assign(&mut self)

Replaces a number with the smallest power of 2 greater than or equal to it.

$x \gets 2^{\lceil \log_2 x \rceil}$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if the next power of 2 is greater than the type’s maximum value.

§Examples

See here.

source§

impl NextPowerOf2Assign for u32

source§

fn next_power_of_2_assign(&mut self)

Replaces a number with the smallest power of 2 greater than or equal to it.

$x \gets 2^{\lceil \log_2 x \rceil}$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if the next power of 2 is greater than the type’s maximum value.

§Examples

See here.

source§

impl NextPowerOf2Assign for u64

source§

fn next_power_of_2_assign(&mut self)

Replaces a number with the smallest power of 2 greater than or equal to it.

$x \gets 2^{\lceil \log_2 x \rceil}$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if the next power of 2 is greater than the type’s maximum value.

§Examples

See here.

source§

impl NextPowerOf2Assign for u128

source§

fn next_power_of_2_assign(&mut self)

Replaces a number with the smallest power of 2 greater than or equal to it.

$x \gets 2^{\lceil \log_2 x \rceil}$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if the next power of 2 is greater than the type’s maximum value.

§Examples

See here.

source§

impl NextPowerOf2Assign for usize

source§

fn next_power_of_2_assign(&mut self)

Replaces a number with the smallest power of 2 greater than or equal to it.

$x \gets 2^{\lceil \log_2 x \rceil}$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if the next power of 2 is greater than the type’s maximum value.

§Examples

See here.

Implementors§