funty

Trait Unsigned

Source
pub trait Unsigned: Integral {
    // Required methods
    fn is_power_of_two(self) -> bool;
    fn next_power_of_two(self) -> Self;
    fn checked_next_power_of_two(self) -> Option<Self>;
}
Expand description

Declare that a type is an unsigned integer.

Required Methods§

Source

fn is_power_of_two(self) -> bool

Returns true if and only if self == 2^k for some k.

Source

fn next_power_of_two(self) -> Self

Returns the smallest power of two greater than or equal to self.

When return value overflows (i.e., self > (1 << (N-1)) for type uN), it panics in debug mode and return value is wrapped to 0 in release mode (the only situation in which method can return 0).

Source

fn checked_next_power_of_two(self) -> Option<Self>

Returns the smallest power of two greater than or equal to n. If the next power of two is greater than the type’s maximum value, None is returned, otherwise the power of two is wrapped in Some.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Unsigned for u8

Source§

impl Unsigned for u16

Source§

impl Unsigned for u32

Source§

impl Unsigned for u64

Source§

impl Unsigned for u128

Source§

impl Unsigned for usize

Implementors§