mycelium_util::math

Trait Logarithm

Source
pub trait Logarithm: Sized {
    // Required methods
    fn log2_ceil(self) -> Self;
    fn log2(self) -> Self;
    fn checked_log(self, base: Self) -> Option<Self>;
    fn log(self, base: Self) -> Self;
}
Expand description

Extension trait adding logarithm methods to integers.

Required Methods§

Source

fn log2_ceil(self) -> Self

Returns ceiling(log2(self)).

Source

fn log2(self) -> Self

Returns log2(self).

Source

fn checked_log(self, base: Self) -> Option<Self>

Returns the integer logarithm base base of self, or None if it is not possible to take the log base base of self.

Source

fn log(self, base: Self) -> Self

Returns the integer logarithm base base of self.

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 Logarithm for usize

Source§

fn log2_ceil(self) -> usize

Source§

fn log2(self) -> usize

Source§

fn checked_log(self, base: usize) -> Option<Self>

Source§

fn log(self, base: usize) -> Self

Implementors§