pub struct u14(/* private fields */);Expand description
A 14-bit integer type.
Wraps the u16 type and ensures that the top two bits are always zero.
Implementations§
Source§impl u14
impl u14
Sourcepub const fn new(raw: u16) -> u14
pub const fn new(raw: u16) -> u14
Creates a restricted int from its non-restricted counterpart by masking off the extra bits.
Sourcepub const fn from_int_lossy(raw: u16) -> u14
pub const fn from_int_lossy(raw: u16) -> u14
Creates a restricted int from its non-restricted counterpart by masking off the extra bits.
Sourcepub fn try_from(raw: u16) -> Option<u14>
pub fn try_from(raw: u16) -> Option<u14>
Returns Some if the raw integer is within range of the restricted integer, and
None otherwise.
Sourcepub fn as_int(self) -> u16
pub fn as_int(self) -> u16
Get the inner integer out of the wrapper. The inner integer is guaranteed to be in range of the restricted wrapper.
Sourcepub fn slice_try_from_int(raw: &[u16]) -> Option<&[u14]>
pub fn slice_try_from_int(raw: &[u16]) -> Option<&[u14]>
Cast a slice of raw integers to a slice of restricted integers, only if there are no out-of-range integers.
Sourcepub fn slice_from_int(raw: &[u16]) -> &[u14]
pub fn slice_from_int(raw: &[u16]) -> &[u14]
Cast a slice of raw integers to a slice of restricted integers.
The slice is truncated up to the first out-of-range integer, if there is any.
Sourcepub unsafe fn slice_from_int_unchecked(raw: &[u16]) -> &[u14]
pub unsafe fn slice_from_int_unchecked(raw: &[u16]) -> &[u14]
Cast a slice of raw integers to a slice of restricted integers.
§Safety
The input slice must not contain any out-of-range integers.
Sourcepub fn slice_try_from_int_mut(raw: &mut [u16]) -> Option<&mut [u14]>
pub fn slice_try_from_int_mut(raw: &mut [u16]) -> Option<&mut [u14]>
Cast a slice of mutable raw integers to a slice of mutable restricted integers, only if there are no out-of-range integers.
Sourcepub fn slice_from_int_mut(raw: &mut [u16]) -> &mut [u14]
pub fn slice_from_int_mut(raw: &mut [u16]) -> &mut [u14]
Cast a slice of mutable raw integers to a slice of mutable restricted integers.
The slice is truncated up to the first out-of-range integer, if there is any.
Sourcepub unsafe fn slice_from_int_unchecked_mut(raw: &mut [u16]) -> &mut [u14]
pub unsafe fn slice_from_int_unchecked_mut(raw: &mut [u16]) -> &mut [u14]
Cast a slice of mutable raw integers to a slice of mutable restricted integers.
§Safety
The input slice must not contain any out-of-range integers.
Sourcepub fn slice_as_int(slice: &[u14]) -> &[u16]
pub fn slice_as_int(slice: &[u14]) -> &[u16]
Cast a slice of restricted integers to the corresponding raw integers.
All integers are guaranteed to be within range of the restricted int.
Trait Implementations§
Source§impl AddAssign for u14
impl AddAssign for u14
Source§fn add_assign(&mut self, other: u14)
fn add_assign(&mut self, other: u14)
+= operation. Read moreSource§impl Ord for u14
impl Ord for u14
Source§impl PartialOrd<u16> for u14
impl PartialOrd<u16> for u14
Source§impl PartialOrd for u14
impl PartialOrd for u14
Source§impl SubAssign for u14
impl SubAssign for u14
Source§fn sub_assign(&mut self, other: u14)
fn sub_assign(&mut self, other: u14)
-= operation. Read moreimpl Copy for u14
impl Eq for u14
impl StructuralPartialEq for u14
Auto Trait Implementations§
impl Freeze for u14
impl RefUnwindSafe for u14
impl Send for u14
impl Sync for u14
impl Unpin for u14
impl UnwindSafe for u14
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more