[][src]Struct bitvec::index::BitMask

#[repr(transparent)]pub struct BitMask<R> where
    R: BitRegister
{ /* fields omitted */ }

A multi-bit selection mask.

Unlike BitSel, which enforces a strict one-hot mask encoding, this mask type permits any number of bits to be set or unset. This is used to accumulate selections for a batch operation on a register.

Construction

It is only constructed by accumulating BitSel values. The chain of custody for safe construction in this module and in order ensures that all masks that are applied to register values can be trusted to not cause memory unsafety.

Implementations

impl<R> BitMask<R> where
    R: BitRegister
[src]

pub const ALL: Self[src]

A full mask.

pub const ZERO: Self[src]

An empty mask.

pub unsafe fn new(mask: R) -> Self[src]

Wraps any R value as a bit-mask.

This constructor is provided to explicitly declare that an operation is discarding the numeric value of an integer and reading it only as a bit-mask.

Parameters

  • mask: Some integer value

Returns

mask wrapped as a bit-mask, with its numeric context discarded.

Safety

This function must only be called within a BitOrder::mask implementation which is verified to be correct.

Prefer accumulating BitSel values using the Sum implementation.

pub fn combine(self, sel: BitSel<R>) -> Self[src]

Creates a new mask with a selector bit activated.

Parameters

  • self
  • sel: The selector bit to activate in the new mask.

Returns

A copy of self, with the selector at sel activated.

pub fn insert(&mut self, sel: BitSel<R>)[src]

Inserts a selector into an existing mask.

Parameters

  • &mut self
  • sel: The selector bit to insert into the mask.

Effects

The selector’s bit in the self mask is activated.

pub fn test(self, sel: BitSel<R>) -> bool[src]

Tests whether a mask contains a given selector bit.

Paramters

  • self
  • sel: The selector bit to test in the self mask.

Returns

Whether self has set the bit at sel.

pub fn value(self) -> R[src]

Views the internal mask value.

Trait Implementations

impl<R> Binary for BitMask<R> where
    R: BitRegister
[src]

impl<R> BitAnd<R> for BitMask<R> where
    R: BitRegister
[src]

type Output = Self

The resulting type after applying the & operator.

impl<R> BitOr<R> for BitMask<R> where
    R: BitRegister
[src]

type Output = Self

The resulting type after applying the | operator.

impl<R: Clone> Clone for BitMask<R> where
    R: BitRegister
[src]

impl<R: Copy> Copy for BitMask<R> where
    R: BitRegister
[src]

impl<R> Debug for BitMask<R> where
    R: BitRegister
[src]

impl<R: Default> Default for BitMask<R> where
    R: BitRegister
[src]

impl<R> Display for BitMask<R> where
    R: BitRegister
[src]

impl<R: Eq> Eq for BitMask<R> where
    R: BitRegister
[src]

impl<R: Hash> Hash for BitMask<R> where
    R: BitRegister
[src]

impl<R> Not for BitMask<R> where
    R: BitRegister
[src]

type Output = Self

The resulting type after applying the ! operator.

impl<R: Ord> Ord for BitMask<R> where
    R: BitRegister
[src]

impl<R: PartialEq> PartialEq<BitMask<R>> for BitMask<R> where
    R: BitRegister
[src]

impl<R: PartialOrd> PartialOrd<BitMask<R>> for BitMask<R> where
    R: BitRegister
[src]

impl<R> StructuralEq for BitMask<R> where
    R: BitRegister
[src]

impl<R> StructuralPartialEq for BitMask<R> where
    R: BitRegister
[src]

impl<R> Sum<BitSel<R>> for BitMask<R> where
    R: BitRegister
[src]

Auto Trait Implementations

impl<R> RefUnwindSafe for BitMask<R> where
    R: RefUnwindSafe

impl<R> Send for BitMask<R>

impl<R> Sync for BitMask<R>

impl<R> Unpin for BitMask<R>

impl<R> UnwindSafe for BitMask<R> where
    R: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Conv for T[src]

impl<T> FmtForward for T[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pipe for T[src]

impl<T> PipeAsRef for T[src]

impl<T> PipeBorrow for T[src]

impl<T> PipeDeref for T[src]

impl<T> PipeRef for T[src]

impl<T> Tap for T[src]

impl<T, U> TapAsRef<U> for T where
    U: ?Sized
[src]

impl<T, U> TapBorrow<U> for T where
    U: ?Sized
[src]

impl<T> TapDeref for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T> TryConv for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.