pub struct Nibble(/* private fields */);Expand description
A byte-width nibble, representing a 4-bit unit of data.
While this type does not explicitly guarantee any
particular memory layout, it does guarantee that the
null pointer optimization
applies: Option<Nibble> will always have the same size
and alignment as Nibble.
Implementations§
source§impl Nibble
impl Nibble
sourcepub const BITS: u32 = 4u32
pub const BITS: u32 = 4u32
The minimum number of bits required to represent a nibble.
As opposed to the primitive integer types, this value is not
the same as std::mem::sizeof<Nibble>() * 8; instead it reflects
the smallest possible size that a nibble could be packed into.
sourcepub const unsafe fn new_unchecked(value: u8) -> Self
pub const unsafe fn new_unchecked(value: u8) -> Self
sourcepub const fn new_checked(value: u8) -> Self
pub const fn new_checked(value: u8) -> Self
sourcepub const fn get(&self) -> u8
pub const fn get(&self) -> u8
Consumes self and returns a u8 representing its value, guaranteed
to be at most 15.
sourcepub const fn pair_from_byte(value: u8) -> (Self, Self)
pub const fn pair_from_byte(value: u8) -> (Self, Self)
Converts a byte (u8) into a pair of nibbles, where
the upper nibble is on the left and the lower nibble is
on the right.
Trait Implementations§
source§impl BitAndAssign for Nibble
impl BitAndAssign for Nibble
source§fn bitand_assign(&mut self, rhs: Self)
fn bitand_assign(&mut self, rhs: Self)
Performs the
&= operation. Read moresource§impl BitOrAssign for Nibble
impl BitOrAssign for Nibble
source§fn bitor_assign(&mut self, rhs: Self)
fn bitor_assign(&mut self, rhs: Self)
Performs the
|= operation. Read moresource§impl BitXorAssign for Nibble
impl BitXorAssign for Nibble
source§fn bitxor_assign(&mut self, rhs: Self)
fn bitxor_assign(&mut self, rhs: Self)
Performs the
^= operation. Read moresource§impl Ord for Nibble
impl Ord for Nibble
source§impl PartialEq for Nibble
impl PartialEq for Nibble
source§impl PartialOrd for Nibble
impl PartialOrd for Nibble
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self and other) and is used by the <=
operator. Read moresource§impl ShlAssign<u8> for Nibble
impl ShlAssign<u8> for Nibble
source§fn shl_assign(&mut self, rhs: u8)
fn shl_assign(&mut self, rhs: u8)
Performs the
<<= operation. Read moresource§impl ShrAssign<u8> for Nibble
impl ShrAssign<u8> for Nibble
source§fn shr_assign(&mut self, rhs: u8)
fn shr_assign(&mut self, rhs: u8)
Performs the
>>= operation. Read moreimpl Copy for Nibble
impl Eq for Nibble
impl StructuralPartialEq for Nibble
Auto Trait Implementations§
impl Freeze for Nibble
impl RefUnwindSafe for Nibble
impl Send for Nibble
impl Sync for Nibble
impl Unpin for Nibble
impl UnwindSafe for Nibble
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