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

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

An electrical position counter within a register element R.

This type is a counter in the ring 0 .. R::BITS, and serves to mark an electrical address of a real bit. It is the shift distance in the expression 1 << n. It is only produced by applying a BitOrder::at transformation to some BitIdx produced by this library.

Type Parameters

  • R: The register element that this position governs.

Validity

Values of this type are required to be in the range 0 .. R::BITS. Any value not less than R::BITS makes the program invalid, and will likely cause a crash. In addition, BitOrder::at has a list of requirements that its implementations must uphold in order to make construction of this type semantically correct in a program.

Construction

This type is publicly constructible. bitvec will only request its creation by calling BitOrder::at, and has no sites that can publicly accept untrusted values.

Implementations

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

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

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

Parameters

  • value: The counter value to mark as a position. This must be in the range 0 .. R::BITS.

Returns

This returns Some(value) when it is in the valid range 0 .. R::BITS, and None when it is not.

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

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

Parameters

  • value: The counter value to mark as a position. This must be in the range 0 .. R::BITS.

Returns

This returns value, marked as a valid position.

Safety

If the value is outside the valid range, then the program is incorrect. Debug builds will panic; release builds do not inspect the value.

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

Removes the position wrapper, leaving the internal counter.

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

Computes the bit selector corresponding to self.

This is always 1 << self.pos.

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

Computes the bit selector for self as an accessor mask.

This is a type-cast over Self::select.

Trait Implementations

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

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> 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.