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

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

A one-hot selection mask, to be applied to a memory element M.

This type selects exactly one bit, and is produced by the conversion of a semantic BitIdx to a BitPos through a BitOrder implementation, and then applying 1 << pos. Values of this type are used to select only the bit specified by a BitIdx when performing memory operations.

Type Parameters

  • M: The register type that values of this type govern.

Validity

Values of this type are required to have exactly one bit set to 1 and all other bits set to 0.

Construction

This type is only constructed from BitPos values, which are themselves only constructed by a chain of known-good BitIdx values passed into known-correct BitOrder implementations. As such, bitvec can use BitSel values with full confidence that they are correct in the surrounding context.

Implementations

impl<M> BitSel<M> where
    M: BitMemory
[src]

pub unsafe fn new(sel: M) -> Option<Self>[src]

Wraps a selector value as a known-good selection of an M element.

Parameters

  • sel: A one-hot selection mask of a bit in an M element.

Returns

If sel does not have exactly one bit set, this returns None; otherwise, it returns a BitSel wrapping the sel value.

Safety

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

pub unsafe fn new_unchecked(sel: M) -> Self[src]

Wraps a selector value as an assumed-good selection of an M element.

Parameters

  • sel: A one-hot selection mask of a bit in an M element.

Returns

sel wrapped in a BitSel.

Safety

sel must have exactly one bit set high and all others low. In debug builds, invalid sel values cause a panic; release builds do not check the input.

This function must only be called in a correct BitOrder::select implementation.

pub fn mask(self) -> BitMask<M> where
    M: BitMemory
[src]

Converts the selector into a bit mask.

This is a type-cast.

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

Views the internal selector value.

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

Ranges over all possible selector values.

Trait Implementations

impl<M: Clone> Clone for BitSel<M> where
    M: BitMemory
[src]

impl<M: Copy> Copy for BitSel<M> where
    M: BitMemory
[src]

impl<M> Debug for BitSel<M> where
    M: BitMemory
[src]

impl<M: Default> Default for BitSel<M> where
    M: BitMemory
[src]

impl<M> Display for BitSel<M> where
    M: BitMemory
[src]

impl<M: Eq> Eq for BitSel<M> where
    M: BitMemory
[src]

impl<M: Hash> Hash for BitSel<M> where
    M: BitMemory
[src]

impl<M: Ord> Ord for BitSel<M> where
    M: BitMemory
[src]

impl<M: PartialEq> PartialEq<BitSel<M>> for BitSel<M> where
    M: BitMemory
[src]

impl<M: PartialOrd> PartialOrd<BitSel<M>> for BitSel<M> where
    M: BitMemory
[src]

impl<M> StructuralEq for BitSel<M> where
    M: BitMemory
[src]

impl<M> StructuralPartialEq for BitSel<M> where
    M: BitMemory
[src]

impl<M> Sum<BitSel<M>> for BitMask<M> where
    M: BitMemory
[src]

Auto Trait Implementations

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

impl<M> Send for BitSel<M>

impl<M> Sync for BitSel<M>

impl<M> Unpin for BitSel<M>

impl<M> UnwindSafe for BitSel<M> where
    M: 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.