pub struct U22(/* private fields */);Expand description
A 22-bit unsigned integer.
Implementations§
Source§impl U22
impl U22
Sourcepub const fn from_u32(n: u32) -> Result<Self, U22FromU32Error>
pub const fn from_u32(n: u32) -> Result<Self, U22FromU32Error>
Creates a new 22-bit integer from the given 32-bit integer if it is small enough to fit.
§Examples
assert_eq!(U22::from_u32(42).map(U22::as_u32), Ok(42));
assert_eq!(U22::from_u32(U22::MAX).map(U22::as_u32), Ok(U22::MAX));
assert_eq!(U22::from_u32(U22::MAX + 1), Err(U22FromU32Error(U22::MAX + 1)));Sourcepub const unsafe fn from_u32_unchecked(n: u32) -> Self
pub const unsafe fn from_u32_unchecked(n: u32) -> Self
Trait Implementations§
Source§impl From<U22> for PackedChar
impl From<U22> for PackedChar
Source§impl Ord for U22
impl Ord for U22
Source§impl PartialOrd for U22
impl PartialOrd for U22
impl Copy for U22
impl Eq for U22
impl StructuralPartialEq for U22
Auto Trait Implementations§
impl Freeze for U22
impl RefUnwindSafe for U22
impl Send for U22
impl Sync for U22
impl Unpin for U22
impl UnwindSafe for U22
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