Skip to main content

Mask

Trait Mask 

Source
pub trait Mask:
    PrimInt
    + ConstZero
    + ConstOne
    + Bounded
    + Euclid {
    const ALL_SELECTED: Self;
    const NONE_SELECTED: Self;
    const ONE_SELECTED: Self;
    const MAX_SELECTIONS: u32;

    // Required method
    fn mask_to_indices(self) -> impl Iterator<Item = usize>;

    // Provided method
    fn index_to_mask(index: usize) -> Self { ... }
}
Expand description

An integer mask trait

Required Associated Constants§

Source

const ALL_SELECTED: Self

An instance of the mask with all indices selected.

Source

const NONE_SELECTED: Self

An instance of the mask with no indices selected.

Source

const ONE_SELECTED: Self

An instance of the mask with the lowest index (1) selected.

Source

const MAX_SELECTIONS: u32

The number of bits in the mask

Required Methods§

Source

fn mask_to_indices(self) -> impl Iterator<Item = usize>

Convert this mask into an iterator of indices.

Provided Methods§

Source

fn index_to_mask(index: usize) -> Self

Convert an index into an instance of this mask.

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 Mask for u8

Source§

const ALL_SELECTED: Self = Self::MAX

Source§

const NONE_SELECTED: Self = 0

Source§

const ONE_SELECTED: Self = 1

Source§

const MAX_SELECTIONS: u32 = Self::BITS

Source§

fn mask_to_indices(self) -> impl Iterator<Item = usize>

Source§

impl Mask for u16

Source§

const ALL_SELECTED: Self = Self::MAX

Source§

const NONE_SELECTED: Self = 0

Source§

const ONE_SELECTED: Self = 1

Source§

const MAX_SELECTIONS: u32 = Self::BITS

Source§

fn mask_to_indices(self) -> impl Iterator<Item = usize>

Source§

impl Mask for u32

Source§

const ALL_SELECTED: Self = Self::MAX

Source§

const NONE_SELECTED: Self = 0

Source§

const ONE_SELECTED: Self = 1

Source§

const MAX_SELECTIONS: u32 = Self::BITS

Source§

fn mask_to_indices(self) -> impl Iterator<Item = usize>

Source§

impl Mask for u64

Source§

const ALL_SELECTED: Self = Self::MAX

Source§

const NONE_SELECTED: Self = 0

Source§

const ONE_SELECTED: Self = 1

Source§

const MAX_SELECTIONS: u32 = Self::BITS

Source§

fn mask_to_indices(self) -> impl Iterator<Item = usize>

Source§

impl Mask for u128

Source§

const ALL_SELECTED: Self = Self::MAX

Source§

const NONE_SELECTED: Self = 0

Source§

const ONE_SELECTED: Self = 1

Source§

const MAX_SELECTIONS: u32 = Self::BITS

Source§

fn mask_to_indices(self) -> impl Iterator<Item = usize>

Implementors§