#[repr(transparent)]pub struct u15(_);
Expand description
A 15-bit integer type.
Wraps the u16
type and ensures that the top bit is always zero.
Implementations§
source§impl u15
impl u15
sourcepub const fn new(raw: u16) -> u15
pub const fn new(raw: u16) -> u15
Creates a restricted int from its non-restricted counterpart by masking off the extra bits.
sourcepub const fn from_int_lossy(raw: u16) -> u15
pub const fn from_int_lossy(raw: u16) -> u15
Creates a restricted int from its non-restricted counterpart by masking off the extra bits.
sourcepub fn try_from(raw: u16) -> Option<u15>
pub fn try_from(raw: u16) -> Option<u15>
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<&[u15]>
pub fn slice_try_from_int(raw: &[u16]) -> Option<&[u15]>
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]) -> &[u15]
pub fn slice_from_int(raw: &[u16]) -> &[u15]
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]) -> &[u15]
pub unsafe fn slice_from_int_unchecked(raw: &[u16]) -> &[u15]
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 [u15]>
pub fn slice_try_from_int_mut(raw: &mut [u16]) -> Option<&mut [u15]>
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 [u15]
pub fn slice_from_int_mut(raw: &mut [u16]) -> &mut [u15]
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 [u15]
pub unsafe fn slice_from_int_unchecked_mut(raw: &mut [u16]) -> &mut [u15]
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: &[u15]) -> &[u16]
pub fn slice_as_int(slice: &[u15]) -> &[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<u15> for u15
impl AddAssign<u15> for u15
source§fn add_assign(&mut self, other: Self)
fn add_assign(&mut self, other: Self)
+=
operation. Read moresource§impl Ord for u15
impl Ord for u15
source§impl PartialOrd<u15> for u15
impl PartialOrd<u15> for u15
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl PartialOrd<u15> for u16
impl PartialOrd<u15> for u16
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl PartialOrd<u16> for u15
impl PartialOrd<u16> for u15
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl SubAssign<u15> for u15
impl SubAssign<u15> for u15
source§fn sub_assign(&mut self, other: Self)
fn sub_assign(&mut self, other: Self)
-=
operation. Read more