Struct bitvec::index::BitSel[][src]

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

A one-hot selection mask for a register element R.

This type selects exactly one bit in a register. It is used to apply test and write operations into memory.

Type Parameters

  • R: The register element this selector governs.

Validity

Values of this type are required to have exactly one bit set high, and all others set low.

Construction

This type is only constructed from the BitPos::select and BitOrder::select functions. It is always equivalent to 1 << BitPos::unwrap.

The chain of custody, from known-good BitIdx values, through proven-good BitOrder implementations, into BitPos and then BitSel, proves that values of this type are always correct to apply to underlying memory.

Implementations

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

pub fn new(value: R) -> Option<Self>[src]

Wraps a counter value as a known-good selection of an R register.

Parameters

  • value: A one-hot selection mask of a bit in an R register.

Returns

If value is a power of two (exactly one bit set high and all others set low), it returns Some of a BitSel wrapping the value.

pub unsafe fn new_unchecked(value: R) -> Self[src]

Wraps a counter value as an assumed-good selection of an R register.

Parameters

  • value: A one-hot selection mask of a bit in an R register.

Returns

value wrapped in a BitSel.

Safety

value must be a power of two: one bit set high and all others set low. In debug builds, invalid values cause a panic; release builds do not check the input.

This function must only be called in a BitOrder::select implementation that is verified to be correct.

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

Removes the selector wrapper, leaving the internal counter.

pub fn mask(self) -> BitMask<R>[src]

Computes a bit-mask for self. This is a type-cast.

pub fn range_all(
) -> impl Iterator<Item = Self> + DoubleEndedIterator + ExactSizeIterator + FusedIterator
[src]

Iterates over all possible selector values.

Trait Implementations

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Auto Trait Implementations

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

impl<R> Send for BitSel<R>

impl<R> Sync for BitSel<R>

impl<R> Unpin for BitSel<R>

impl<R> UnwindSafe for BitSel<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 where
    T: ?Sized
[src]

impl<T> Tap 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.