pub trait SignedInt: Int + Signed {
type U: UnsignedInt;
Show 29 methods
// Required methods
fn checked_abs(self) -> Option<Self>;
fn saturating_abs(self) -> Self;
fn wrapping_abs(self) -> Self;
fn overflowing_abs(self) -> (Self, bool);
fn unsigned_abs(self) -> Self::U;
fn checked_neg(self) -> Option<Self>;
fn saturating_neg(self) -> Self;
fn wrapping_neg(self) -> Self;
fn overflowing_neg(self) -> (Self, bool);
fn checked_add_unsigned(self, rhs: Self::U) -> Option<Self>;
fn saturating_add_unsigned(self, rhs: Self::U) -> Self;
fn wrapping_add_unsigned(self, rhs: Self::U) -> Self;
fn overflowing_add_unsigned(self, rhs: Self::U) -> (Self, bool);
fn checked_sub_unsigned(self, rhs: Self::U) -> Option<Self>;
fn saturating_sub_unsigned(self, rhs: Self::U) -> Self;
fn wrapping_sub_unsigned(self, rhs: Self::U) -> Self;
fn overflowing_sub_unsigned(self, rhs: Self::U) -> (Self, bool);
fn cast_unsigned(self) -> Self::U;
fn signum(self) -> Self;
fn isqrt(self) -> Self;
fn checked_isqrt(self) -> Option<Self>;
fn div_euclid(self, rhs: Self) -> Self;
fn rem_euclid(self, rhs: Self) -> Self;
fn ilog(self, base: Self) -> u32;
fn ilog2(self) -> u32;
fn ilog10(self) -> u32;
fn checked_ilog(self, base: Self) -> Option<u32>;
fn checked_ilog2(self) -> Option<u32>;
fn checked_ilog10(self) -> Option<u32>;
}Expand description
Signed integers.
Required Associated Types§
Sourcetype U: UnsignedInt
type U: UnsignedInt
The unsigned integer type with the same size.
Required Methods§
Sourcefn checked_abs(self) -> Option<Self>
fn checked_abs(self) -> Option<Self>
Checked absolute value.
Sourcefn saturating_abs(self) -> Self
fn saturating_abs(self) -> Self
Saturating absolute value.
Sourcefn wrapping_abs(self) -> Self
fn wrapping_abs(self) -> Self
Wrapping (modular) absolute value.
Sourcefn overflowing_abs(self) -> (Self, bool)
fn overflowing_abs(self) -> (Self, bool)
Computes the absolute value of self, with overflow information.
Sourcefn unsigned_abs(self) -> Self::U
fn unsigned_abs(self) -> Self::U
Computes the absolute value of self without any wrapping or panicking.
Sourcefn checked_neg(self) -> Option<Self>
fn checked_neg(self) -> Option<Self>
Checked negation.
Sourcefn saturating_neg(self) -> Self
fn saturating_neg(self) -> Self
Saturating integer negation.
Sourcefn wrapping_neg(self) -> Self
fn wrapping_neg(self) -> Self
Wrapping (modular) negation.
Sourcefn overflowing_neg(self) -> (Self, bool)
fn overflowing_neg(self) -> (Self, bool)
Negates self, overflowing if this is equal to the minimum value.
Sourcefn checked_add_unsigned(self, rhs: Self::U) -> Option<Self>
fn checked_add_unsigned(self, rhs: Self::U) -> Option<Self>
Checked addition with an unsigned integer.
Sourcefn saturating_add_unsigned(self, rhs: Self::U) -> Self
fn saturating_add_unsigned(self, rhs: Self::U) -> Self
Saturating addition with an unsigned integer.
Sourcefn wrapping_add_unsigned(self, rhs: Self::U) -> Self
fn wrapping_add_unsigned(self, rhs: Self::U) -> Self
Wrapping (modular) addition with an unsigned integer.
Sourcefn overflowing_add_unsigned(self, rhs: Self::U) -> (Self, bool)
fn overflowing_add_unsigned(self, rhs: Self::U) -> (Self, bool)
Calculates self + rhs with an unsigned rhs.
Sourcefn checked_sub_unsigned(self, rhs: Self::U) -> Option<Self>
fn checked_sub_unsigned(self, rhs: Self::U) -> Option<Self>
Checked subtraction with an unsigned integer.
Sourcefn saturating_sub_unsigned(self, rhs: Self::U) -> Self
fn saturating_sub_unsigned(self, rhs: Self::U) -> Self
Saturating subtraction with an unsigned integer.
Sourcefn wrapping_sub_unsigned(self, rhs: Self::U) -> Self
fn wrapping_sub_unsigned(self, rhs: Self::U) -> Self
Wrapping (modular) subtraction with an unsigned integer.
Sourcefn overflowing_sub_unsigned(self, rhs: Self::U) -> (Self, bool)
fn overflowing_sub_unsigned(self, rhs: Self::U) -> (Self, bool)
Calculates self - rhs with an unsigned rhs.
Sourcefn cast_unsigned(self) -> Self::U
fn cast_unsigned(self) -> Self::U
Returns the bit pattern of self reinterpreted as an unsigned integer of the same size.
Sourcefn checked_isqrt(self) -> Option<Self>
fn checked_isqrt(self) -> Option<Self>
Checked integer square root.
Sourcefn div_euclid(self, rhs: Self) -> Self
fn div_euclid(self, rhs: Self) -> Self
Calculates the quotient of Euclidean division of self by rhs.
Sourcefn rem_euclid(self, rhs: Self) -> Self
fn rem_euclid(self, rhs: Self) -> Self
Calculates the least nonnegative remainder of self (mod rhs).
Sourcefn ilog(self, base: Self) -> u32
fn ilog(self, base: Self) -> u32
Returns the logarithm of the number with respect to an arbitrary base, rounded down.
Sourcefn checked_ilog(self, base: Self) -> Option<u32>
fn checked_ilog(self, base: Self) -> Option<u32>
Checked integer logarithm to base.
Sourcefn checked_ilog2(self) -> Option<u32>
fn checked_ilog2(self) -> Option<u32>
Checked base 2 logarithm.
Sourcefn checked_ilog10(self) -> Option<u32>
fn checked_ilog10(self) -> Option<u32>
Checked base 10 logarithm.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.