pub trait NextPowerOf2Assign {
    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

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.

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.

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.

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.

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.

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.

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.

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