pub type NonExtremeU16 = NonValueU16<{ u16::MAX }>;
Expand description
An unsigned integer that is known not to equal its most extreme value (MAX
).
Unlike the NonValue*
types in general, this type alias implements
the Default
and ConstDefault
traits.
Aliased Type§
struct NonExtremeU16(/* private fields */);
Implementations
Source§impl<const V: u16> NonValueU16<V>
impl<const V: u16> NonValueU16<V>
Sourcepub const VALID_VALUES: u16 = 65_535u16
pub const VALID_VALUES: u16 = 65_535u16
Returns the number of valid values.
Sourcepub const INVALID_VALUES: u16 = 1u16
pub const INVALID_VALUES: u16 = 1u16
Returns the number of invalid values.
Sourcepub const fn new(value: u16) -> Option<Self> ⓘ
pub const fn new(value: u16) -> Option<Self> ⓘ
Returns a NonValueU16
with the given value
, if it is not equal to V
.
Sourcepub const unsafe fn new_unchecked(value: u16) -> Self
pub const unsafe fn new_unchecked(value: u16) -> Self
Sourcepub const fn checked_add(&self, other: u16) -> NumResult<Self>
pub const fn checked_add(&self, other: u16) -> NumResult<Self>
Sourcepub const fn checked_sub(&self, other: u16) -> NumResult<Self>
pub const fn checked_sub(&self, other: u16) -> NumResult<Self>
Sourcepub const fn strict_add(&self, other: u16) -> Self
pub const fn strict_add(&self, other: u16) -> Self
Strict integer addition. Computes self + rhs
.
§Panics
Panics on overflow or if the result equals the forbidden value V
.
Sourcepub const fn strict_sub(&self, other: u16) -> Self
pub const fn strict_sub(&self, other: u16) -> Self
Strict integer substration. Computes self - rhs
.
§Panics
Panics on overflow or if the result equals the forbidden value V
.
Sourcepub const fn saturating_add(&self, other: u16) -> Self
pub const fn saturating_add(&self, other: u16) -> Self
Saturating integer addition. Computes self + rhs
.
Saturates at the numeric bounds instead of overflowing.
If the result would equal V
it will return V - 1
.
Sourcepub const fn saturating_sub(&self, other: u16) -> Self
pub const fn saturating_sub(&self, other: u16) -> Self
Saturating integer substration. Computes self - rhs
.
Saturates at the numeric bounds instead of overflowing.
If the result would equal V
it will return V + 1
.
Sourcepub const fn wrapping_add(&self, other: u16) -> Self
pub const fn wrapping_add(&self, other: u16) -> Self
Wraping integer addition. Computes self + rhs
.
Wraps at the numeric bounds instead of overflowing.
If the result would equal V
it will return V + 1
.
Sourcepub const fn wrapping_sub(&self, other: u16) -> Self
pub const fn wrapping_sub(&self, other: u16) -> Self
Wraping integer subtraction. Computes self - rhs
.
Wraps at the numeric bounds instead of overflowing.
If the result would equal V
it will return V - 1
.
Trait Implementations§
Source§impl ConstDefault for NonExtremeU16
impl ConstDefault for NonExtremeU16
Source§impl Default for NonExtremeU16
impl Default for NonExtremeU16
Source§impl<const V: u16> Binary for NonValueU16<V>
impl<const V: u16> Binary for NonValueU16<V>
Source§impl<const V: u16> BitSized<{$IP::BYTE_SIZE * 8}> for NonValueU16<V>
impl<const V: u16> BitSized<{$IP::BYTE_SIZE * 8}> for NonValueU16<V>
Source§const BIT_SIZE: usize = _
const BIT_SIZE: usize = _
Source§const MIN_BYTE_SIZE: usize = _
const MIN_BYTE_SIZE: usize = _
Source§fn bit_size(&self) -> usize
fn bit_size(&self) -> usize
Source§fn min_byte_size(&self) -> usize
fn min_byte_size(&self) -> usize
Source§impl<const V: u16> CheckedBitPattern for NonValueU16<V>
impl<const V: u16> CheckedBitPattern for NonValueU16<V>
Source§type Bits = u16
type Bits = u16
Self
must have the same layout as the specified Bits
except for
the possible invalid bit patterns being checked during
is_valid_bit_pattern
.Source§fn is_valid_bit_pattern(bits: &Self::Bits) -> bool
fn is_valid_bit_pattern(bits: &Self::Bits) -> bool
bits
as &Self
.Source§impl<const V: u16> Clone for NonValueU16<V>
impl<const V: u16> Clone for NonValueU16<V>
Source§fn clone(&self) -> NonValueU16<V>
fn clone(&self) -> NonValueU16<V>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more