#[repr(transparent)]pub struct U75(_);
Expand description
The 75-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 U75
impl U75
sourcepub const BITS: u32 = 75u32
pub const BITS: u32 = 75u32
The bit width of this type.
See also: UBitint::BITS
sourcepub const MASK: u128 = 37_778_931_862_957_161_709_567u128
pub const MASK: u128 = 37_778_931_862_957_161_709_567u128
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
MIN
andMAX
, 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<U75> for U75
impl AddAssign<U75> for U75
source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
+=
operation. Read moresource§impl BitAndAssign<U75> for U75
impl BitAndAssign<U75> for U75
source§fn bitand_assign(&mut self, rhs: Self)
fn bitand_assign(&mut self, rhs: Self)
&=
operation. Read moresource§impl BitOrAssign<U75> for U75
impl BitOrAssign<U75> for U75
source§fn bitor_assign(&mut self, rhs: Self)
fn bitor_assign(&mut self, rhs: Self)
|=
operation. Read moresource§impl BitXorAssign<U75> for U75
impl BitXorAssign<U75> for U75
source§fn bitxor_assign(&mut self, rhs: Self)
fn bitxor_assign(&mut self, rhs: Self)
^=
operation. Read moresource§impl CheckedAdd for U75
impl CheckedAdd for U75
source§fn checked_add(&self, v: &Self) -> Option<Self>
fn checked_add(&self, v: &Self) -> Option<Self>
None
is
returned.source§impl CheckedDiv for U75
impl CheckedDiv for U75
source§fn checked_div(&self, v: &Self) -> Option<Self>
fn checked_div(&self, v: &Self) -> Option<Self>
None
is returned.source§impl CheckedMul for U75
impl CheckedMul for U75
source§fn checked_mul(&self, v: &Self) -> Option<Self>
fn checked_mul(&self, v: &Self) -> Option<Self>
None
is returned.source§impl CheckedRem for U75
impl CheckedRem for U75
source§impl CheckedSub for U75
impl CheckedSub for U75
source§fn checked_sub(&self, v: &Self) -> Option<Self>
fn checked_sub(&self, v: &Self) -> Option<Self>
None
is returned.source§impl DivAssign<U75> for U75
impl DivAssign<U75> for U75
source§fn div_assign(&mut self, rhs: Self)
fn div_assign(&mut self, rhs: Self)
/=
operation. Read moresource§impl FromStr for U75
impl FromStr for U75
§type Err = ParseBitintError
type Err = ParseBitintError
source§impl MulAssign<U75> for U75
impl MulAssign<U75> for U75
source§fn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
*=
operation. Read moresource§impl Num for U75
impl Num for U75
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 U75
impl Ord for U75
source§impl PartialEq<U75> for U75
impl PartialEq<U75> for U75
source§impl PartialOrd<U75> for U75
impl PartialOrd<U75> for U75
source§impl RemAssign<U75> for U75
impl RemAssign<U75> for U75
source§fn rem_assign(&mut self, rhs: Self)
fn rem_assign(&mut self, rhs: Self)
%=
operation. Read moresource§impl SubAssign<U75> for U75
impl SubAssign<U75> for U75
source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
-=
operation. Read moresource§impl TryFrom<u128> for U75
impl TryFrom<u128> for U75
§type Error = RangeError
type Error = RangeError
source§impl UBitint for U75
impl UBitint for U75
source§const MASK: u128 = 37_778_931_862_957_161_709_567u128
const MASK: u128 = 37_778_931_862_957_161_709_567u128
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 U75
impl WrappingAdd for U75
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 U75
impl WrappingMul for U75
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 U75
impl WrappingSub for U75
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.