Skip to main content

HighestOne

Trait HighestOne 

Source
pub trait HighestOne: Sized {
    // Required method
    fn highest_one(self) -> Option<u32>;
}
Expand description

Finds the index of the highest one-bit.

Required Methods§

Source

fn highest_one(self) -> Option<u32>

Returns the index of the highest bit set to one, or None if the value is zero.

use const_num_traits::HighestOne;

assert_eq!(HighestOne::highest_one(0b0101_0000u8), Some(6));
assert_eq!(HighestOne::highest_one(0u8), None);

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl HighestOne for i8

Source§

impl HighestOne for i16

Source§

impl HighestOne for i32

Source§

impl HighestOne for i64

Source§

impl HighestOne for i128

Source§

impl HighestOne for isize

Source§

impl HighestOne for u8

Source§

impl HighestOne for u16

Source§

impl HighestOne for u32

Source§

impl HighestOne for u64

Source§

impl HighestOne for u128

Source§

impl HighestOne for usize

Implementors§