Expand description
An i128 that is known to be in the range MIN..=MAX.
Implementations
sourceimpl<const MIN: i128, const MAX: i128> I128<MIN, MAX>
impl<const MIN: i128, const MAX: i128> I128<MIN, MAX>
sourcepub const unsafe fn new_unchecked(value: i128) -> Self
pub const unsafe fn new_unchecked(value: i128) -> Self
Creates a ranged integer without checking the value.
Safety
The value must be within the range MIN..=MAX.
sourcepub const fn new(value: i128) -> Option<Self>
pub const fn new(value: i128) -> Option<Self>
Creates a ranged integer if the given value is in the range
MIN..=MAX.
sourcepub const fn checked_add(self, rhs: i128) -> Option<Self>
pub const fn checked_add(self, rhs: i128) -> Option<Self>
Checked integer addition. Computes self + rhs, returning
None if the resulting value is out of range.
sourcepub const fn checked_sub(self, rhs: i128) -> Option<Self>
pub const fn checked_sub(self, rhs: i128) -> Option<Self>
Checked integer addition. Computes self - rhs, returning
None if the resulting value is out of range.
sourcepub const fn checked_mul(self, rhs: i128) -> Option<Self>
pub const fn checked_mul(self, rhs: i128) -> Option<Self>
Checked integer addition. Computes self * rhs, returning
None if the resulting value is out of range.
sourcepub const fn checked_div(self, rhs: i128) -> Option<Self>
pub const fn checked_div(self, rhs: i128) -> Option<Self>
Checked integer addition. Computes self / rhs, returning
None if rhs == 0 or if the resulting value is out of range.
sourcepub const fn checked_div_euclid(self, rhs: i128) -> Option<Self>
pub const fn checked_div_euclid(self, rhs: i128) -> Option<Self>
Checked Euclidean division. Computes self.div_euclid(rhs),
returning None if rhs == 0 or if the resulting value is out
of range.
sourcepub const fn checked_rem(self, rhs: i128) -> Option<Self>
pub const fn checked_rem(self, rhs: i128) -> Option<Self>
Checked integer remainder. Computes self % rhs, returning
None if rhs == 0 or if the resulting value is out of range.
sourcepub const fn checked_rem_euclid(self, rhs: i128) -> Option<Self>
pub const fn checked_rem_euclid(self, rhs: i128) -> Option<Self>
Checked Euclidean remainder. Computes self.rem_euclid(rhs),
returning None if rhs == 0 or if the resulting value is out
of range.
sourcepub const fn checked_neg(self) -> Option<Self>
pub const fn checked_neg(self) -> Option<Self>
Checked negation. Computes -self, returning None if the
resulting value is out of range.
sourcepub const fn checked_shl(self, rhs: u32) -> Option<Self>
pub const fn checked_shl(self, rhs: u32) -> Option<Self>
Checked shift left. Computes self << rhs, returning None if
the resulting value is out of range.
sourcepub const fn checked_shr(self, rhs: u32) -> Option<Self>
pub const fn checked_shr(self, rhs: u32) -> Option<Self>
Checked shift right. Computes self >> rhs, returning None if
the resulting value is out of range.
sourcepub const fn checked_abs(self) -> Option<Self>
pub const fn checked_abs(self) -> Option<Self>
Checked absolute value. Computes self.abs(), returning None
if the resulting value is out of range.
sourcepub const fn checked_pow(self, exp: u32) -> Option<Self>
pub const fn checked_pow(self, exp: u32) -> Option<Self>
Checked exponentiation. Computes self.pow(exp), returning
None if the resulting value is out of range.
sourcepub const fn saturating_add(self, rhs: i128) -> Self
pub const fn saturating_add(self, rhs: i128) -> Self
Saturating integer addition. Computes self + rhs, saturating
at the numeric bounds.
sourcepub const fn saturating_sub(self, rhs: i128) -> Self
pub const fn saturating_sub(self, rhs: i128) -> Self
Saturating integer subtraction. Computes self - rhs,
saturating at the numeric bounds.
sourcepub const fn saturating_neg(self) -> Self
pub const fn saturating_neg(self) -> Self
Saturating integer negation. Computes self - rhs, saturating
at the numeric bounds.
sourcepub const fn saturating_abs(self) -> Self
pub const fn saturating_abs(self) -> Self
Saturating absolute value. Computes self.abs(), saturating at
the numeric bounds.
sourcepub const fn saturating_mul(self, rhs: i128) -> Self
pub const fn saturating_mul(self, rhs: i128) -> Self
Saturating integer multiplication. Computes self * rhs,
saturating at the numeric bounds.
sourcepub const fn saturating_pow(self, exp: u32) -> Self
pub const fn saturating_pow(self, exp: u32) -> Self
Saturating integer exponentiation. Computes self.pow(exp),
saturating at the numeric bounds.
Trait Implementations
sourceimpl<const MIN: i128, const MAX: i128> Bounded for I128<MIN, MAX>
Available on crate feature num only.
impl<const MIN: i128, const MAX: i128> Bounded for I128<MIN, MAX>
num only.sourceimpl<'de, const MIN: i128, const MAX: i128> Deserialize<'de> for I128<MIN, MAX>
Available on crate feature serde only.
impl<'de, const MIN: i128, const MAX: i128> Deserialize<'de> for I128<MIN, MAX>
serde only.sourcefn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
sourceimpl<const MIN: i128, const MAX: i128> Distribution<I128<MIN, MAX>> for Standard
Available on crate feature rand only.
impl<const MIN: i128, const MAX: i128> Distribution<I128<MIN, MAX>> for Standard
rand only.sourcefn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> I128<MIN, MAX>
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> I128<MIN, MAX>
Generate a random value of T, using rng as the source of randomness.
sourcefn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T> where
R: Rng,
fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T> where
R: Rng,
Create an iterator that generates random values of T, using rng as
the source of randomness. Read more
sourceimpl<const MIN: i128, const MAX: i128> Ord for I128<MIN, MAX>
impl<const MIN: i128, const MAX: i128> Ord for I128<MIN, MAX>
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl<const MIN: i128, const MAX: i128> PartialEq<I128<MIN, MAX>> for i128
impl<const MIN: i128, const MAX: i128> PartialEq<I128<MIN, MAX>> for i128
sourceimpl<const MIN_A: i128, const MAX_A: i128, const MIN_B: i128, const MAX_B: i128> PartialEq<I128<MIN_B, MAX_B>> for I128<MIN_A, MAX_A>
impl<const MIN_A: i128, const MAX_A: i128, const MIN_B: i128, const MAX_B: i128> PartialEq<I128<MIN_B, MAX_B>> for I128<MIN_A, MAX_A>
sourceimpl<const MIN: i128, const MAX: i128> PartialEq<i128> for I128<MIN, MAX>
impl<const MIN: i128, const MAX: i128> PartialEq<i128> for I128<MIN, MAX>
sourceimpl<const MIN: i128, const MAX: i128> PartialOrd<I128<MIN, MAX>> for i128
impl<const MIN: i128, const MAX: i128> PartialOrd<I128<MIN, MAX>> for i128
sourcefn partial_cmp(&self, other: &I128<MIN, MAX>) -> Option<Ordering>
fn partial_cmp(&self, other: &I128<MIN, MAX>) -> Option<Ordering>
This method returns an ordering between self and other values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self and other) and is used by the <=
operator. Read more
sourceimpl<const MIN_A: i128, const MAX_A: i128, const MIN_B: i128, const MAX_B: i128> PartialOrd<I128<MIN_B, MAX_B>> for I128<MIN_A, MAX_A>
impl<const MIN_A: i128, const MAX_A: i128, const MIN_B: i128, const MAX_B: i128> PartialOrd<I128<MIN_B, MAX_B>> for I128<MIN_A, MAX_A>
sourcefn partial_cmp(&self, other: &I128<MIN_B, MAX_B>) -> Option<Ordering>
fn partial_cmp(&self, other: &I128<MIN_B, MAX_B>) -> Option<Ordering>
This method returns an ordering between self and other values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self and other) and is used by the <=
operator. Read more
sourceimpl<const MIN: i128, const MAX: i128> PartialOrd<i128> for I128<MIN, MAX>
impl<const MIN: i128, const MAX: i128> PartialOrd<i128> for I128<MIN, MAX>
sourcefn partial_cmp(&self, other: &i128) -> Option<Ordering>
fn partial_cmp(&self, other: &i128) -> Option<Ordering>
This method returns an ordering between self and other values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self and other) and is used by the <=
operator. Read more
sourceimpl<const MIN: i128, const MAX: i128> Serialize for I128<MIN, MAX>
Available on crate feature serde only.
impl<const MIN: i128, const MAX: i128> Serialize for I128<MIN, MAX>
serde only.impl<const MIN: i128, const MAX: i128> Copy for I128<MIN, MAX>
impl<const MIN: i128, const MAX: i128> Eq for I128<MIN, MAX>
impl<const MIN: i128, const MAX: i128> StructuralEq for I128<MIN, MAX>
Auto Trait Implementations
impl<const MIN: i128, const MAX: i128> RefUnwindSafe for I128<MIN, MAX>
impl<const MIN: i128, const MAX: i128> Send for I128<MIN, MAX>
impl<const MIN: i128, const MAX: i128> Sync for I128<MIN, MAX>
impl<const MIN: i128, const MAX: i128> Unpin for I128<MIN, MAX>
impl<const MIN: i128, const MAX: i128> UnwindSafe for I128<MIN, MAX>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more