Struct bitvec::index::BitPos [−][src]
An electrical position of a single bit within a memory element M.
This type is used as the shift distance in the expression 1 << shamt. It is
only produced by the translation of a semantic BitIdx<M> 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
M: The register type that values of this type govern.
Validity
Values of this type are required to be in the range 0 .. M::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<M> BitPos<M> where
M: BitMemory, [src]
M: BitMemory,
pub unsafe fn new(pos: u8) -> Option<Self>[src]
Wraps a value as a known-good position within an M element.
Parameters
pos: An electrical position of a bit within anMelement.
Returns
If pos is outside the valid range 0 .. M::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 M element.
Parameters
pos: An electrical position within anMelement.
Returns
pos wrapped in a BitPos.
Safety
pos must be within the valid range 0 .. M::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<M>[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 M selecting the bit specified by self.
pub fn mask(self) -> BitMask<M>[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 M selecting only the bit specified by self.
pub fn value(self) -> u8[src]
Views the internal position value.
Trait Implementations
impl<M: Clone> Clone for BitPos<M> where
M: BitMemory, [src]
M: BitMemory,
impl<M: Copy> Copy for BitPos<M> where
M: BitMemory, [src]
M: BitMemory,
impl<M> Debug for BitPos<M> where
M: BitMemory, [src]
M: BitMemory,
impl<M: Default> Default for BitPos<M> where
M: BitMemory, [src]
M: BitMemory,
impl<M: Eq> Eq for BitPos<M> where
M: BitMemory, [src]
M: BitMemory,
impl<M: Hash> Hash for BitPos<M> where
M: BitMemory, [src]
M: BitMemory,
fn hash<__H: Hasher>(&self, state: &mut __H)[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, 1.3.0[src]
H: Hasher,
impl<M: Ord> Ord for BitPos<M> where
M: BitMemory, [src]
M: BitMemory,
fn cmp(&self, other: &BitPos<M>) -> Ordering[src]
#[must_use]pub fn max(self, other: Self) -> Self1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self1.50.0[src]
impl<M: PartialEq> PartialEq<BitPos<M>> for BitPos<M> where
M: BitMemory, [src]
M: BitMemory,
impl<M: PartialOrd> PartialOrd<BitPos<M>> for BitPos<M> where
M: BitMemory, [src]
M: BitMemory,
fn partial_cmp(&self, other: &BitPos<M>) -> Option<Ordering>[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool1.0.0[src]
impl<M> StructuralEq for BitPos<M> where
M: BitMemory, [src]
M: BitMemory,
impl<M> StructuralPartialEq for BitPos<M> where
M: BitMemory, [src]
M: BitMemory,
Auto Trait Implementations
impl<M> RefUnwindSafe for BitPos<M> where
M: RefUnwindSafe,
M: RefUnwindSafe,
impl<M> Send for BitPos<M>
impl<M> Sync for BitPos<M>
impl<M> Unpin for BitPos<M>
impl<M> UnwindSafe for BitPos<M> where
M: UnwindSafe,
M: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> Conv for T[src]
impl<T> FmtForward for T[src]
pub fn fmt_binary(self) -> FmtBinary<Self> where
Self: Binary, [src]
Self: Binary,
pub fn fmt_display(self) -> FmtDisplay<Self> where
Self: Display, [src]
Self: Display,
pub fn fmt_lower_exp(self) -> FmtLowerExp<Self> where
Self: LowerExp, [src]
Self: LowerExp,
pub fn fmt_lower_hex(self) -> FmtLowerHex<Self> where
Self: LowerHex, [src]
Self: LowerHex,
pub fn fmt_octal(self) -> FmtOctal<Self> where
Self: Octal, [src]
Self: Octal,
pub fn fmt_pointer(self) -> FmtPointer<Self> where
Self: Pointer, [src]
Self: Pointer,
pub fn fmt_upper_exp(self) -> FmtUpperExp<Self> where
Self: UpperExp, [src]
Self: UpperExp,
pub fn fmt_upper_hex(self) -> FmtUpperHex<Self> where
Self: UpperHex, [src]
Self: UpperHex,
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> Pipe for T[src]
impl<T> PipeAsRef for T[src]
pub fn pipe_as_ref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
Self: AsRef<T>,
R: 'a,
T: 'a, [src]
Self: AsRef<T>,
R: 'a,
T: 'a,
pub fn pipe_as_mut<'a, T, R>(
&'a mut self,
func: impl FnOnce(&'a mut T) -> R
) -> R where
Self: AsMut<T>,
R: 'a,
T: 'a, [src]
&'a mut self,
func: impl FnOnce(&'a mut T) -> R
) -> R where
Self: AsMut<T>,
R: 'a,
T: 'a,
impl<T> PipeBorrow for T[src]
pub fn pipe_borrow<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
Self: Borrow<T>,
R: 'a,
T: 'a, [src]
Self: Borrow<T>,
R: 'a,
T: 'a,
pub fn pipe_borrow_mut<'a, T, R>(
&'a mut self,
func: impl FnOnce(&'a mut T) -> R
) -> R where
Self: BorrowMut<T>,
R: 'a,
T: 'a, [src]
&'a mut self,
func: impl FnOnce(&'a mut T) -> R
) -> R where
Self: BorrowMut<T>,
R: 'a,
T: 'a,
impl<T> PipeDeref for T[src]
pub fn pipe_deref<'a, R>(
&'a self,
func: impl FnOnce(&'a Self::Target) -> R
) -> R where
Self: Deref,
R: 'a, [src]
&'a self,
func: impl FnOnce(&'a Self::Target) -> R
) -> R where
Self: Deref,
R: 'a,
pub fn pipe_deref_mut<'a, R>(
&'a mut self,
func: impl FnOnce(&'a mut Self::Target) -> R
) -> R where
Self: DerefMut,
R: 'a, [src]
&'a mut self,
func: impl FnOnce(&'a mut Self::Target) -> R
) -> R where
Self: DerefMut,
R: 'a,
impl<T> PipeRef for T[src]
pub fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R where
R: 'a, [src]
R: 'a,
pub fn pipe_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R where
R: 'a, [src]
R: 'a,
impl<T> Tap for T[src]
pub fn tap<F, R>(self, func: F) -> Self where
F: FnOnce(&Self) -> R, [src]
F: FnOnce(&Self) -> R,
pub fn tap_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&Self) -> R, [src]
F: FnOnce(&Self) -> R,
pub fn tap_mut<F, R>(self, func: F) -> Self where
F: FnOnce(&mut Self) -> R, [src]
F: FnOnce(&mut Self) -> R,
pub fn tap_mut_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&mut Self) -> R, [src]
F: FnOnce(&mut Self) -> R,
impl<T, U> TapAsRef<U> for T where
U: ?Sized, [src]
U: ?Sized,
pub fn tap_ref<F, R>(self, func: F) -> Self where
Self: AsRef<T>,
F: FnOnce(&T) -> R, [src]
Self: AsRef<T>,
F: FnOnce(&T) -> R,
pub fn tap_ref_dbg<F, R>(self, func: F) -> Self where
Self: AsRef<T>,
F: FnOnce(&T) -> R, [src]
Self: AsRef<T>,
F: FnOnce(&T) -> R,
pub fn tap_ref_mut<F, R>(self, func: F) -> Self where
Self: AsMut<T>,
F: FnOnce(&mut T) -> R, [src]
Self: AsMut<T>,
F: FnOnce(&mut T) -> R,
pub fn tap_ref_mut_dbg<F, R>(self, func: F) -> Self where
Self: AsMut<T>,
F: FnOnce(&mut T) -> R, [src]
Self: AsMut<T>,
F: FnOnce(&mut T) -> R,
impl<T, U> TapBorrow<U> for T where
U: ?Sized, [src]
U: ?Sized,
pub fn tap_borrow<F, R>(self, func: F) -> Self where
Self: Borrow<T>,
F: FnOnce(&T) -> R, [src]
Self: Borrow<T>,
F: FnOnce(&T) -> R,
pub fn tap_borrow_dbg<F, R>(self, func: F) -> Self where
Self: Borrow<T>,
F: FnOnce(&T) -> R, [src]
Self: Borrow<T>,
F: FnOnce(&T) -> R,
pub fn tap_borrow_mut<F, R>(self, func: F) -> Self where
Self: BorrowMut<T>,
F: FnOnce(&mut T) -> R, [src]
Self: BorrowMut<T>,
F: FnOnce(&mut T) -> R,
pub fn tap_borrow_mut_dbg<F, R>(self, func: F) -> Self where
Self: BorrowMut<T>,
F: FnOnce(&mut T) -> R, [src]
Self: BorrowMut<T>,
F: FnOnce(&mut T) -> R,
impl<T> TapDeref for T[src]
pub fn tap_deref<F, R>(self, func: F) -> Self where
Self: Deref,
F: FnOnce(&Self::Target) -> R, [src]
Self: Deref,
F: FnOnce(&Self::Target) -> R,
pub fn tap_deref_dbg<F, R>(self, func: F) -> Self where
Self: Deref,
F: FnOnce(&Self::Target) -> R, [src]
Self: Deref,
F: FnOnce(&Self::Target) -> R,
pub fn tap_deref_mut<F, R>(self, func: F) -> Self where
Self: DerefMut,
F: FnOnce(&mut Self::Target) -> R, [src]
Self: DerefMut,
F: FnOnce(&mut Self::Target) -> R,
pub fn tap_deref_mut_dbg<F, R>(self, func: F) -> Self where
Self: DerefMut,
F: FnOnce(&mut Self::Target) -> R, [src]
Self: DerefMut,
F: FnOnce(&mut Self::Target) -> R,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn clone_into(&self, target: &mut T)[src]
impl<T> TryConv for T[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,