Struct bitint::U75

source ·
#[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

source

pub const BITS: u32 = 75u32

The bit width of this type.

See also: UBitint::BITS

source

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

source

pub const MIN: Self = _

The smallest value of this type.

See also: UBitint::MIN

source

pub const MAX: Self = _

The largest value of this type.

See also: UBitint::MAX

source

pub const ZERO: Self = _

The value 0 represented in this type.

See also: UBitint::ZERO, num_traits::Zero

source

pub const ONE: Self = _

The value 1 represented in this type.

See also: UBitint::ONE, num_traits::One

source

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.

source

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.

source

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.

source

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.

source

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 and MAX, inclusive: value >= Self::MIN.as_primitive() && value <= Self::MAX.as_primitive()

This method is a const variant of UBitint::is_in_range.

source

pub const fn checked_add(self, rhs: Self) -> Option<Self>

Checked integer addition. Computes self + rhs, returning None if overflow occurred.

source

pub const unsafe fn unchecked_add(self, rhs: Self) -> Self

Available on 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.

source

pub const fn checked_sub(self, rhs: Self) -> Option<Self>

Checked integer subtraction. Computes self - rhs, returning None if overflow occurred.

source

pub const unsafe fn unchecked_sub(self, rhs: Self) -> Self

Available on 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.

source

pub const fn checked_mul(self, rhs: Self) -> Option<Self>

Checked integer multiplication. Computes self * rhs, returning None if overflow occurred.

source

pub const unsafe fn unchecked_mul(self, rhs: Self) -> Self

Available on 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.

source

pub const fn checked_div(self, rhs: Self) -> Option<Self>

Checked integer division. Computes self / rhs, returning None if rhs == 0.

source

pub const fn checked_rem(self, rhs: Self) -> Option<Self>

Checked integer remainder. Computes self % rhs, returning None if rhs == 0.

source

pub const fn wrapping_add(self, rhs: Self) -> Self

Wrapping (modular) addition. Computes self + rhs, wrapping around at the boundary of the type.

source

pub const fn wrapping_sub(self, rhs: Self) -> Self

Wrapping (modular) subtraction. Computes self - rhs, wrapping around at the boundary of the type.

source

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 Add<U75> for U75

§

type Output = U75

The resulting type after applying the + operator.
source§

fn add(self, rhs: Self) -> Self

Performs the + operation. Read more
source§

impl AddAssign<U75> for U75

source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
source§

impl BitAnd<U75> for U75

§

type Output = U75

The resulting type after applying the & operator.
source§

fn bitand(self, rhs: Self) -> Self

Performs the & operation. Read more
source§

impl BitAndAssign<U75> for U75

source§

fn bitand_assign(&mut self, rhs: Self)

Performs the &= operation. Read more
source§

impl BitOr<U75> for U75

§

type Output = U75

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: Self) -> Self

Performs the | operation. Read more
source§

impl BitOrAssign<U75> for U75

source§

fn bitor_assign(&mut self, rhs: Self)

Performs the |= operation. Read more
source§

impl BitXor<U75> for U75

§

type Output = U75

The resulting type after applying the ^ operator.
source§

fn bitxor(self, rhs: Self) -> Self

Performs the ^ operation. Read more
source§

impl BitXorAssign<U75> for U75

source§

fn bitxor_assign(&mut self, rhs: Self)

Performs the ^= operation. Read more
source§

impl CheckedAdd for U75

source§

fn checked_add(&self, v: &Self) -> Option<Self>

Adds two numbers, checking for overflow. If overflow happens, None is returned.
source§

impl CheckedDiv for U75

source§

fn checked_div(&self, v: &Self) -> Option<Self>

Divides two numbers, checking for underflow, overflow and division by zero. If any of that happens, None is returned.
source§

impl CheckedMul for U75

source§

fn checked_mul(&self, v: &Self) -> Option<Self>

Multiplies two numbers, checking for underflow or overflow. If underflow or overflow happens, None is returned.
source§

impl CheckedRem for U75

source§

fn checked_rem(&self, v: &Self) -> Option<Self>

Finds the remainder of dividing two numbers, checking for underflow, overflow and division by zero. If any of that happens, None is returned. Read more
source§

impl CheckedSub for U75

source§

fn checked_sub(&self, v: &Self) -> Option<Self>

Subtracts two numbers, checking for underflow. If underflow happens, None is returned.
source§

impl Clone for U75

source§

fn clone(&self) -> U75

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for U75

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Display for U75

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Div<U75> for U75

§

type Output = U75

The resulting type after applying the / operator.
source§

fn div(self, rhs: Self) -> Self

Performs the / operation. Read more
source§

impl DivAssign<U75> for U75

source§

fn div_assign(&mut self, rhs: Self)

Performs the /= operation. Read more
source§

impl From<U75> for u128

source§

fn from(value: U75) -> Self

Converts to this type from the input type.
source§

impl FromStr for U75

§

type Err = ParseBitintError

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<Self, ParseBitintError>

Parses a string s to return a value of this type. Read more
source§

impl Hash for U75

source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Mul<U75> for U75

§

type Output = U75

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Self) -> Self

Performs the * operation. Read more
source§

impl MulAssign<U75> for U75

source§

fn mul_assign(&mut self, rhs: Self)

Performs the *= operation. Read more
source§

impl Not for U75

§

type Output = U75

The resulting type after applying the ! operator.
source§

fn not(self) -> Self

Performs the unary ! operation. Read more
source§

impl Num for U75

§

type FromStrRadixErr = ParseBitintError

source§

fn from_str_radix(str: &str, radix: u32) -> Result<Self, ParseBitintError>

Convert from a string and radix (typically 2..=36). Read more
source§

impl One for U75

source§

fn one() -> Self

Returns the multiplicative identity element of Self, 1. Read more
source§

fn is_one(&self) -> bool

Returns true if self is equal to the multiplicative identity. Read more
source§

fn set_one(&mut self)

Sets self to the multiplicative identity element of Self, 1.
source§

impl Ord for U75

source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl PartialEq<U75> for U75

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd<U75> for U75

source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
source§

fn lt(&self, other: &Self) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
source§

fn le(&self, other: &Self) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
source§

fn gt(&self, other: &Self) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
source§

fn ge(&self, other: &Self) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Rem<U75> for U75

§

type Output = U75

The resulting type after applying the % operator.
source§

fn rem(self, rhs: Self) -> Self

Performs the % operation. Read more
source§

impl RemAssign<U75> for U75

source§

fn rem_assign(&mut self, rhs: Self)

Performs the %= operation. Read more
source§

impl Sub<U75> for U75

§

type Output = U75

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Self) -> Self

Performs the - operation. Read more
source§

impl SubAssign<U75> for U75

source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
source§

impl TryFrom<u128> for U75

§

type Error = RangeError

The type returned in the event of a conversion error.
source§

fn try_from(value: u128) -> Result<Self, RangeError>

Performs the conversion.
source§

impl UBitint for U75

§

type Primitive = u128

The primitive type that this type wraps.
source§

const BITS: u32 = 75u32

The bit width of this type.
source§

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.
source§

const MIN: Self = Self::MIN

The smallest value of this type.
source§

const MAX: Self = Self::MAX

The largest value of this type.
source§

const ZERO: Self = Self::ZERO

The value 0 represented in this type.
source§

const ONE: Self = Self::ONE

The value 1 represented in this type.
source§

fn new(value: u128) -> Option<Self>

Creates an unsigned 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

Creates an unsigned bitint value by masking off the upper bits of a primitive value. Read more
source§

unsafe fn new_unchecked(value: u128) -> Self

Creates an unsigned bitint value from a primitive value without checking whether it is in range for this type. Read more
source§

fn is_in_range(value: u128) -> bool

Checks whether a primitive value is in range for this type. Read more
source§

impl WrappingAdd for U75

source§

fn wrapping_add(&self, v: &Self) -> Self

Wrapping (modular) addition. Computes self + other, wrapping around at the boundary of the type.
source§

impl WrappingMul for U75

source§

fn wrapping_mul(&self, v: &Self) -> Self

Wrapping (modular) multiplication. Computes self * other, wrapping around at the boundary of the type.
source§

impl WrappingSub for U75

source§

fn wrapping_sub(&self, v: &Self) -> Self

Wrapping (modular) subtraction. Computes self - other, wrapping around at the boundary of the type.
source§

impl Zero for U75

source§

fn zero() -> Self

Returns the additive identity element of Self, 0. Read more
source§

fn is_zero(&self) -> bool

Returns true if self is equal to the additive identity.
source§

fn set_zero(&mut self)

Sets self to the additive identity element of Self, 0.
source§

impl Copy for U75

source§

impl Eq for U75

Auto Trait Implementations§

§

impl RefUnwindSafe for U75

§

impl Send for U75

§

impl Sync for U75

§

impl Unpin for U75

§

impl UnwindSafe for U75

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> NumAssign for Twhere T: Num + NumAssignOps<T>,

source§

impl<T, Rhs> NumAssignOps<Rhs> for Twhere T: AddAssign<Rhs> + SubAssign<Rhs> + MulAssign<Rhs> + DivAssign<Rhs> + RemAssign<Rhs>,

source§

impl<T, Rhs, Output> NumOps<Rhs, Output> for Twhere T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>,