#[repr(transparent)]pub struct U97(_);Expand description
The 97-bit unsigned bitint type.
Layout
This type is #[repr(transparent)] to u128, but imposes additional invariants.
Invariants
The value is represented in the least significant bits of a u128. The unused most significant bits are always clear.
Implementations§
source§impl U97
impl U97
sourcepub const BITS: u32 = 97u32
pub const BITS: u32 = 97u32
The bit width of this type.
See also: UBitint::BITS
sourcepub const MASK: u128 = 158_456_325_028_528_675_187_087_900_671u128
pub const MASK: u128 = 158_456_325_028_528_675_187_087_900_671u128
The bit mask for the bits that may be set in values of this type.
See also: UBitint::MASK
sourcepub const MIN: Self = _
pub const MIN: Self = _
The smallest value of this type.
See also: UBitint::MIN
sourcepub const MAX: Self = _
pub const MAX: Self = _
The largest value of this type.
See also: UBitint::MAX
sourcepub const ZERO: Self = _
pub const ZERO: Self = _
The value 0 represented in this type.
See also: UBitint::ZERO, num_traits::Zero
sourcepub const ONE: Self = _
pub const ONE: Self = _
The value 1 represented in this type.
See also: UBitint::ONE, num_traits::One
sourcepub const fn new(value: u128) -> Option<Self>
pub const fn new(value: u128) -> Option<Self>
Creates a bitint from a primitive value if it is in range for
this type, as determined by is_in_range.
This method is a const variant of UBitint::new.
sourcepub const fn new_masked(value: u128) -> Self
pub const fn new_masked(value: u128) -> Self
Creates a bitint by masking off the upper bits of a primitive
value.
This conversion is lossless if the value is in range for this
type, as determined by is_in_range.
This method is a const variant of UBitint::new_masked.
sourcepub const unsafe fn new_unchecked(value: u128) -> Self
pub const unsafe fn new_unchecked(value: u128) -> Self
Creates a bitint from a primitive value without checking
whether it is in range for this type.
Safety
The value must be in range for this type, as determined by
is_in_range.
This method is a const variant of UBitint::new_unchecked.
sourcepub const fn to_primitive(self) -> u128
pub const fn to_primitive(self) -> u128
Converts the value to a primitive type.
The result is in range for this type, as determined by
is_in_range.
sourcepub const fn is_in_range(value: u128) -> bool
pub const fn is_in_range(value: u128) -> bool
Checks whether a primitive value is in range for this type.
There are a few equivalent ways to express this check.
- The unused most significant bits are clear:
(value & !Self::MASK) == 0 - The value is between
MINandMAX, inclusive:value >= Self::MIN.as_primitive() && value <= Self::MAX.as_primitive()
This method is a const variant of UBitint::is_in_range.
sourcepub const fn checked_add(self, rhs: Self) -> Option<Self>
pub const fn checked_add(self, rhs: Self) -> Option<Self>
Checked integer addition. Computes self + rhs, returning None if overflow occurred.
sourcepub const unsafe fn unchecked_add(self, rhs: Self) -> Self
Available on unchecked_math only.
pub const unsafe fn unchecked_add(self, rhs: Self) -> Self
unchecked_math only.Unchecked integer addition. Computes self + rhs, assuming overflow cannot occur.
Safety
The result must be in range for this type, as determined by is_in_range.
sourcepub const fn checked_sub(self, rhs: Self) -> Option<Self>
pub const fn checked_sub(self, rhs: Self) -> Option<Self>
Checked integer subtraction. Computes self - rhs, returning None if overflow occurred.
sourcepub const unsafe fn unchecked_sub(self, rhs: Self) -> Self
Available on unchecked_math only.
pub const unsafe fn unchecked_sub(self, rhs: Self) -> Self
unchecked_math only.Unchecked integer subtraction. Computes self - rhs, assuming overflow cannot occur.
Safety
The result must be in range for this type, as determined by is_in_range.
sourcepub const fn checked_mul(self, rhs: Self) -> Option<Self>
pub const fn checked_mul(self, rhs: Self) -> Option<Self>
Checked integer multiplication. Computes self * rhs, returning None if overflow occurred.
sourcepub const unsafe fn unchecked_mul(self, rhs: Self) -> Self
Available on unchecked_math only.
pub const unsafe fn unchecked_mul(self, rhs: Self) -> Self
unchecked_math only.Unchecked integer multiplication. Computes self * rhs, assuming overflow cannot occur.
Safety
The result must be in range for this type, as determined by is_in_range.
sourcepub const fn checked_div(self, rhs: Self) -> Option<Self>
pub const fn checked_div(self, rhs: Self) -> Option<Self>
Checked integer division. Computes self / rhs, returning None if rhs == 0.
sourcepub const fn checked_rem(self, rhs: Self) -> Option<Self>
pub const fn checked_rem(self, rhs: Self) -> Option<Self>
Checked integer remainder. Computes self % rhs, returning None if rhs == 0.
sourcepub const fn wrapping_add(self, rhs: Self) -> Self
pub const fn wrapping_add(self, rhs: Self) -> Self
Wrapping (modular) addition. Computes self + rhs, wrapping around at the boundary of the type.
sourcepub const fn wrapping_sub(self, rhs: Self) -> Self
pub const fn wrapping_sub(self, rhs: Self) -> Self
Wrapping (modular) subtraction. Computes self - rhs, wrapping around at the boundary of the type.
sourcepub const fn wrapping_mul(self, rhs: Self) -> Self
pub const fn wrapping_mul(self, rhs: Self) -> Self
Wrapping (modular) multiplication. Computes self * rhs, wrapping around at the boundary of the type.
Trait Implementations§
source§impl AddAssign<U97> for U97
impl AddAssign<U97> for U97
source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
+= operation. Read moresource§impl BitAndAssign<U97> for U97
impl BitAndAssign<U97> for U97
source§fn bitand_assign(&mut self, rhs: Self)
fn bitand_assign(&mut self, rhs: Self)
&= operation. Read moresource§impl BitOrAssign<U97> for U97
impl BitOrAssign<U97> for U97
source§fn bitor_assign(&mut self, rhs: Self)
fn bitor_assign(&mut self, rhs: Self)
|= operation. Read moresource§impl BitXorAssign<U97> for U97
impl BitXorAssign<U97> for U97
source§fn bitxor_assign(&mut self, rhs: Self)
fn bitxor_assign(&mut self, rhs: Self)
^= operation. Read moresource§impl CheckedAdd for U97
impl CheckedAdd for U97
source§fn checked_add(&self, v: &Self) -> Option<Self>
fn checked_add(&self, v: &Self) -> Option<Self>
None is
returned.source§impl CheckedDiv for U97
impl CheckedDiv for U97
source§fn checked_div(&self, v: &Self) -> Option<Self>
fn checked_div(&self, v: &Self) -> Option<Self>
None is returned.source§impl CheckedMul for U97
impl CheckedMul for U97
source§fn checked_mul(&self, v: &Self) -> Option<Self>
fn checked_mul(&self, v: &Self) -> Option<Self>
None is returned.source§impl CheckedRem for U97
impl CheckedRem for U97
source§impl CheckedSub for U97
impl CheckedSub for U97
source§fn checked_sub(&self, v: &Self) -> Option<Self>
fn checked_sub(&self, v: &Self) -> Option<Self>
None is returned.source§impl DivAssign<U97> for U97
impl DivAssign<U97> for U97
source§fn div_assign(&mut self, rhs: Self)
fn div_assign(&mut self, rhs: Self)
/= operation. Read moresource§impl FromStr for U97
impl FromStr for U97
§type Err = ParseBitintError
type Err = ParseBitintError
source§impl MulAssign<U97> for U97
impl MulAssign<U97> for U97
source§fn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
*= operation. Read moresource§impl Num for U97
impl Num for U97
type FromStrRadixErr = ParseBitintError
source§fn from_str_radix(str: &str, radix: u32) -> Result<Self, ParseBitintError>
fn from_str_radix(str: &str, radix: u32) -> Result<Self, ParseBitintError>
2..=36). Read moresource§impl Ord for U97
impl Ord for U97
source§impl PartialEq<U97> for U97
impl PartialEq<U97> for U97
source§impl PartialOrd<U97> for U97
impl PartialOrd<U97> for U97
source§impl RemAssign<U97> for U97
impl RemAssign<U97> for U97
source§fn rem_assign(&mut self, rhs: Self)
fn rem_assign(&mut self, rhs: Self)
%= operation. Read moresource§impl SubAssign<U97> for U97
impl SubAssign<U97> for U97
source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
-= operation. Read moresource§impl TryFrom<u128> for U97
impl TryFrom<u128> for U97
§type Error = RangeError
type Error = RangeError
source§impl UBitint for U97
impl UBitint for U97
source§const MASK: u128 = 158_456_325_028_528_675_187_087_900_671u128
const MASK: u128 = 158_456_325_028_528_675_187_087_900_671u128
source§fn new(value: u128) -> Option<Self>
fn new(value: u128) -> Option<Self>
bitint value from a primitive value if it is in
range for this type, as determined by
is_in_range.source§fn new_masked(value: u128) -> Self
fn new_masked(value: u128) -> Self
bitint value by masking off the upper bits of a
primitive value. Read moresource§unsafe fn new_unchecked(value: u128) -> Self
unsafe fn new_unchecked(value: u128) -> Self
bitint value from a primitive value without
checking whether it is in range for this type. Read moresource§impl WrappingAdd for U97
impl WrappingAdd for U97
source§fn wrapping_add(&self, v: &Self) -> Self
fn wrapping_add(&self, v: &Self) -> Self
self + other, wrapping around at the boundary of
the type.source§impl WrappingMul for U97
impl WrappingMul for U97
source§fn wrapping_mul(&self, v: &Self) -> Self
fn wrapping_mul(&self, v: &Self) -> Self
self * other, wrapping around at the boundary
of the type.source§impl WrappingSub for U97
impl WrappingSub for U97
source§fn wrapping_sub(&self, v: &Self) -> Self
fn wrapping_sub(&self, v: &Self) -> Self
self - other, wrapping around at the boundary
of the type.