[][src]Struct bitvec::index::BitPos

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

An electrical position of a single bit within a register R.

This type is used as the shift distance in the expression 1 << shamt. It is only produced by the translation of a semantic BitIdx<R> according to some BitOrder implementation using BitOrder::at. It can only be used for the construction of bit masks used to manipulate a register value during memory access, and serves no other purpose.

Type Parameters

  • R: The register type that these values govern.

Validity

Values of this type are required to be in the range 0 .. R::BITS. Any value outside this range will cause the program state to become invalid, and the library’s behavior is unspecified. The library will never produce such an invalid value, and users are required to do the same.

Construction

This type offers public unsafe constructors. bitvec does not offer any public APIs that take values of this type directly; it always routes through BitOrder implementations. As BitIdx will only be constructed from safe, correct, values, and BitOrder::at is the only BitIdx -> BitPos transform function, all constructed BitPos values are known to be memory-correct.

Implementations

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

pub unsafe fn new(pos: u8) -> Option<Self>[src]

Wraps a value as a known-good position within an R register.

Parameters

  • pos: An electrical position of a bit within an R register.

Returns

If pos is outside the valid range 0 .. R::BITS, this returns None; otherwise, it returns a BitPos wrapping the pos value.

Safety

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

pub unsafe fn new_unchecked(pos: u8) -> Self[src]

Wraps a value as an assumed-good position within an R register.

Parameters

  • pos: An electrical position within an R register.

Returns

pos wrapped in a BitPos.

Safety

pos must be within the valid range 0 .. R::BITS. In debug builds, invalid pos values cause a panic; release builds do not check the input.

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

pub fn select(self) -> BitSel<R>[src]

Constructs a one-hot selection mask from the position counter.

This is a well-typed 1 << pos.

Parameters

  • self

Returns

A one-hot mask for R selecting the bit specified by self.

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

Constructs an untyped bitmask from the position counter.

This removes the one-hot requirement from the selection mask.

Parameters

  • self

Returns

A mask for R selecting only the bit specified by self.

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

Views the internal position value.

Trait Implementations

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

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

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

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

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

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

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

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

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

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

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

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

Auto Trait Implementations

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

impl<R> Send for BitPos<R>

impl<R> Sync for BitPos<R>

impl<R> Unpin for BitPos<R>

impl<R> UnwindSafe for BitPos<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> 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> 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> 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> 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.