pub struct BitField<T: PrimInt>(/* private fields */);
Expand description
A bitfield type.
Built on type of an unsigned integer. It uses the bits to represent the presence or absence of elements.
Implementations§
Source§impl<T: PrimInt> BitField<T>
impl<T: PrimInt> BitField<T>
Sourcepub fn set_bit(&mut self, bit_idx: BitFieldIndex) -> bool
pub fn set_bit(&mut self, bit_idx: BitFieldIndex) -> bool
Set the bit at BitFieldIndex
to 1.
Does not check that the BitFieldIndex
is not out of range.
Returns true
if the value is changed.
Sourcepub fn set_bit_checked(&mut self, bit_idx: BitFieldIndex) -> Option<bool>
pub fn set_bit_checked(&mut self, bit_idx: BitFieldIndex) -> Option<bool>
Set the bit at BitFieldIndex
to 1, if the index is in range..
Check that the BitFieldIndex
is not out of range. Calls set_bit
if
the index is in range.
Returns Some(true)
if the value is changed. Returns None
if the
index is out of range.
pub fn unset_bit(&mut self, bit_idx: BitFieldIndex) -> bool
pub fn unset_bit_checked(&mut self, bit_idx: BitFieldIndex) -> Option<bool>
pub fn merge(&mut self, other: &Self) -> bool
Source§impl<T: PrimInt> BitField<T>
impl<T: PrimInt> BitField<T>
pub fn fill(nb_bits: BitFieldSize) -> Self
pub fn fill_checked(nb_bits: BitFieldSize) -> Option<Self>
pub fn full() -> Self
pub fn empty() -> Self
pub fn single_bit(bit_idx: BitFieldIndex) -> Self
pub fn single_bit_checked(bit_idx: BitFieldIndex) -> Option<Self>
pub fn all_but_single_bit(nb_bits: BitFieldSize, bit_idx: BitFieldIndex) -> Self
pub fn all_but_single_bit_checked( nb_bits: BitFieldSize, bit_idx: BitFieldIndex, ) -> Option<Self>
pub fn all_but_single_bit_full(bit_idx: BitFieldIndex) -> Self
pub fn all_but_single_bit_full_checked(bit_idx: BitFieldIndex) -> Option<Self>
Source§impl<T: PrimInt> BitField<T>
impl<T: PrimInt> BitField<T>
Sourcepub const fn into_inner(self) -> T
pub const fn into_inner(self) -> T
Consumes the BitField
, returning the wrapped value.
Sourcepub fn nb_elements(&self) -> usize
pub fn nb_elements(&self) -> usize
Returns the number of elements present.
Trait Implementations§
Source§impl<T: PrimInt> BitAndAssign for BitField<T>
impl<T: PrimInt> BitAndAssign for BitField<T>
Source§fn bitand_assign(&mut self, rhs: Self)
fn bitand_assign(&mut self, rhs: Self)
Performs the
&=
operation. Read moreSource§impl<T: PrimInt> BitOrAssign for BitField<T>
impl<T: PrimInt> BitOrAssign for BitField<T>
Source§fn bitor_assign(&mut self, rhs: Self)
fn bitor_assign(&mut self, rhs: Self)
Performs the
|=
operation. Read moreSource§impl<T: PrimInt> BitXorAssign for BitField<T>
impl<T: PrimInt> BitXorAssign for BitField<T>
Source§fn bitxor_assign(&mut self, rhs: Self)
fn bitxor_assign(&mut self, rhs: Self)
Performs the
^=
operation. Read moreSource§impl<T: Ord + PrimInt> Ord for BitField<T>
impl<T: Ord + PrimInt> Ord for BitField<T>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<T: PartialOrd + PrimInt> PartialOrd for BitField<T>
impl<T: PartialOrd + PrimInt> PartialOrd for BitField<T>
Source§impl<T: PrimInt> ShlAssign<u8> for BitField<T>
impl<T: PrimInt> ShlAssign<u8> for BitField<T>
Source§fn shl_assign(&mut self, rhs: u8)
fn shl_assign(&mut self, rhs: u8)
Performs the
<<=
operation. Read moreSource§impl<T: PrimInt> ShrAssign<u8> for BitField<T>
impl<T: PrimInt> ShrAssign<u8> for BitField<T>
Source§fn shr_assign(&mut self, rhs: u8)
fn shr_assign(&mut self, rhs: u8)
Performs the
>>=
operation. Read moreimpl<T: Copy + PrimInt> Copy for BitField<T>
impl<T: Eq + PrimInt> Eq for BitField<T>
impl<T: PrimInt> StructuralPartialEq for BitField<T>
Auto Trait Implementations§
impl<T> Freeze for BitField<T>where
T: Freeze,
impl<T> RefUnwindSafe for BitField<T>where
T: RefUnwindSafe,
impl<T> Send for BitField<T>where
T: Send,
impl<T> Sync for BitField<T>where
T: Sync,
impl<T> Unpin for BitField<T>where
T: Unpin,
impl<T> UnwindSafe for BitField<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more