SignedInt

Trait SignedInt 

Source
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§

Source

type U: UnsignedInt

The unsigned integer type with the same size.

Required Methods§

Source

fn checked_abs(self) -> Option<Self>

Checked absolute value.

Source

fn saturating_abs(self) -> Self

Saturating absolute value.

Source

fn wrapping_abs(self) -> Self

Wrapping (modular) absolute value.

Source

fn overflowing_abs(self) -> (Self, bool)

Computes the absolute value of self, with overflow information.

Source

fn unsigned_abs(self) -> Self::U

Computes the absolute value of self without any wrapping or panicking.

Source

fn checked_neg(self) -> Option<Self>

Checked negation.

Source

fn saturating_neg(self) -> Self

Saturating integer negation.

Source

fn wrapping_neg(self) -> Self

Wrapping (modular) negation.

Source

fn overflowing_neg(self) -> (Self, bool)

Negates self, overflowing if this is equal to the minimum value.

Source

fn checked_add_unsigned(self, rhs: Self::U) -> Option<Self>

Checked addition with an unsigned integer.

Source

fn saturating_add_unsigned(self, rhs: Self::U) -> Self

Saturating addition with an unsigned integer.

Source

fn wrapping_add_unsigned(self, rhs: Self::U) -> Self

Wrapping (modular) addition with an unsigned integer.

Source

fn overflowing_add_unsigned(self, rhs: Self::U) -> (Self, bool)

Calculates self + rhs with an unsigned rhs.

Source

fn checked_sub_unsigned(self, rhs: Self::U) -> Option<Self>

Checked subtraction with an unsigned integer.

Source

fn saturating_sub_unsigned(self, rhs: Self::U) -> Self

Saturating subtraction with an unsigned integer.

Source

fn wrapping_sub_unsigned(self, rhs: Self::U) -> Self

Wrapping (modular) subtraction with an unsigned integer.

Source

fn overflowing_sub_unsigned(self, rhs: Self::U) -> (Self, bool)

Calculates self - rhs with an unsigned rhs.

Source

fn cast_unsigned(self) -> Self::U

Returns the bit pattern of self reinterpreted as an unsigned integer of the same size.

Source

fn signum(self) -> Self

Returns a number representing sign of self.

Source

fn isqrt(self) -> Self

Returns the integer square root of a number.

Source

fn checked_isqrt(self) -> Option<Self>

Checked integer square root.

Source

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

Calculates the quotient of Euclidean division of self by rhs.

Source

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

Calculates the least nonnegative remainder of self (mod rhs).

Source

fn ilog(self, base: Self) -> u32

Returns the logarithm of the number with respect to an arbitrary base, rounded down.

Source

fn ilog2(self) -> u32

Returns the base 2 logarithm of the number, rounded down.

Source

fn ilog10(self) -> u32

Returns the base 10 logarithm of the number, rounded down.

Source

fn checked_ilog(self, base: Self) -> Option<u32>

Checked integer logarithm to base.

Source

fn checked_ilog2(self) -> Option<u32>

Checked base 2 logarithm.

Source

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.

Implementations on Foreign Types§

Source§

impl SignedInt for i8

Source§

type U = u8

Source§

fn checked_abs(self) -> Option<Self>

Source§

fn saturating_abs(self) -> Self

Source§

fn wrapping_abs(self) -> Self

Source§

fn overflowing_abs(self) -> (Self, bool)

Source§

fn unsigned_abs(self) -> Self::U

Source§

fn checked_neg(self) -> Option<Self>

Source§

fn saturating_neg(self) -> Self

Source§

fn wrapping_neg(self) -> Self

Source§

fn overflowing_neg(self) -> (Self, bool)

Source§

fn checked_add_unsigned(self, rhs: Self::U) -> Option<Self>

Source§

fn saturating_add_unsigned(self, rhs: Self::U) -> Self

Source§

fn wrapping_add_unsigned(self, rhs: Self::U) -> Self

Source§

fn overflowing_add_unsigned(self, rhs: Self::U) -> (Self, bool)

Source§

fn checked_sub_unsigned(self, rhs: Self::U) -> Option<Self>

Source§

fn saturating_sub_unsigned(self, rhs: Self::U) -> Self

Source§

fn wrapping_sub_unsigned(self, rhs: Self::U) -> Self

Source§

fn overflowing_sub_unsigned(self, rhs: Self::U) -> (Self, bool)

Source§

fn cast_unsigned(self) -> Self::U

Source§

fn signum(self) -> Self

Source§

fn isqrt(self) -> Self

Source§

fn checked_isqrt(self) -> Option<Self>

Source§

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

Source§

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

Source§

fn ilog(self, base: Self) -> u32

Source§

fn ilog2(self) -> u32

Source§

fn ilog10(self) -> u32

Source§

fn checked_ilog(self, base: Self) -> Option<u32>

Source§

fn checked_ilog2(self) -> Option<u32>

Source§

fn checked_ilog10(self) -> Option<u32>

Source§

impl SignedInt for i16

Source§

type U = u16

Source§

fn checked_abs(self) -> Option<Self>

Source§

fn saturating_abs(self) -> Self

Source§

fn wrapping_abs(self) -> Self

Source§

fn overflowing_abs(self) -> (Self, bool)

Source§

fn unsigned_abs(self) -> Self::U

Source§

fn checked_neg(self) -> Option<Self>

Source§

fn saturating_neg(self) -> Self

Source§

fn wrapping_neg(self) -> Self

Source§

fn overflowing_neg(self) -> (Self, bool)

Source§

fn checked_add_unsigned(self, rhs: Self::U) -> Option<Self>

Source§

fn saturating_add_unsigned(self, rhs: Self::U) -> Self

Source§

fn wrapping_add_unsigned(self, rhs: Self::U) -> Self

Source§

fn overflowing_add_unsigned(self, rhs: Self::U) -> (Self, bool)

Source§

fn checked_sub_unsigned(self, rhs: Self::U) -> Option<Self>

Source§

fn saturating_sub_unsigned(self, rhs: Self::U) -> Self

Source§

fn wrapping_sub_unsigned(self, rhs: Self::U) -> Self

Source§

fn overflowing_sub_unsigned(self, rhs: Self::U) -> (Self, bool)

Source§

fn cast_unsigned(self) -> Self::U

Source§

fn signum(self) -> Self

Source§

fn isqrt(self) -> Self

Source§

fn checked_isqrt(self) -> Option<Self>

Source§

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

Source§

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

Source§

fn ilog(self, base: Self) -> u32

Source§

fn ilog2(self) -> u32

Source§

fn ilog10(self) -> u32

Source§

fn checked_ilog(self, base: Self) -> Option<u32>

Source§

fn checked_ilog2(self) -> Option<u32>

Source§

fn checked_ilog10(self) -> Option<u32>

Source§

impl SignedInt for i32

Source§

type U = u32

Source§

fn checked_abs(self) -> Option<Self>

Source§

fn saturating_abs(self) -> Self

Source§

fn wrapping_abs(self) -> Self

Source§

fn overflowing_abs(self) -> (Self, bool)

Source§

fn unsigned_abs(self) -> Self::U

Source§

fn checked_neg(self) -> Option<Self>

Source§

fn saturating_neg(self) -> Self

Source§

fn wrapping_neg(self) -> Self

Source§

fn overflowing_neg(self) -> (Self, bool)

Source§

fn checked_add_unsigned(self, rhs: Self::U) -> Option<Self>

Source§

fn saturating_add_unsigned(self, rhs: Self::U) -> Self

Source§

fn wrapping_add_unsigned(self, rhs: Self::U) -> Self

Source§

fn overflowing_add_unsigned(self, rhs: Self::U) -> (Self, bool)

Source§

fn checked_sub_unsigned(self, rhs: Self::U) -> Option<Self>

Source§

fn saturating_sub_unsigned(self, rhs: Self::U) -> Self

Source§

fn wrapping_sub_unsigned(self, rhs: Self::U) -> Self

Source§

fn overflowing_sub_unsigned(self, rhs: Self::U) -> (Self, bool)

Source§

fn cast_unsigned(self) -> Self::U

Source§

fn signum(self) -> Self

Source§

fn isqrt(self) -> Self

Source§

fn checked_isqrt(self) -> Option<Self>

Source§

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

Source§

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

Source§

fn ilog(self, base: Self) -> u32

Source§

fn ilog2(self) -> u32

Source§

fn ilog10(self) -> u32

Source§

fn checked_ilog(self, base: Self) -> Option<u32>

Source§

fn checked_ilog2(self) -> Option<u32>

Source§

fn checked_ilog10(self) -> Option<u32>

Source§

impl SignedInt for i64

Source§

type U = u64

Source§

fn checked_abs(self) -> Option<Self>

Source§

fn saturating_abs(self) -> Self

Source§

fn wrapping_abs(self) -> Self

Source§

fn overflowing_abs(self) -> (Self, bool)

Source§

fn unsigned_abs(self) -> Self::U

Source§

fn checked_neg(self) -> Option<Self>

Source§

fn saturating_neg(self) -> Self

Source§

fn wrapping_neg(self) -> Self

Source§

fn overflowing_neg(self) -> (Self, bool)

Source§

fn checked_add_unsigned(self, rhs: Self::U) -> Option<Self>

Source§

fn saturating_add_unsigned(self, rhs: Self::U) -> Self

Source§

fn wrapping_add_unsigned(self, rhs: Self::U) -> Self

Source§

fn overflowing_add_unsigned(self, rhs: Self::U) -> (Self, bool)

Source§

fn checked_sub_unsigned(self, rhs: Self::U) -> Option<Self>

Source§

fn saturating_sub_unsigned(self, rhs: Self::U) -> Self

Source§

fn wrapping_sub_unsigned(self, rhs: Self::U) -> Self

Source§

fn overflowing_sub_unsigned(self, rhs: Self::U) -> (Self, bool)

Source§

fn cast_unsigned(self) -> Self::U

Source§

fn signum(self) -> Self

Source§

fn isqrt(self) -> Self

Source§

fn checked_isqrt(self) -> Option<Self>

Source§

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

Source§

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

Source§

fn ilog(self, base: Self) -> u32

Source§

fn ilog2(self) -> u32

Source§

fn ilog10(self) -> u32

Source§

fn checked_ilog(self, base: Self) -> Option<u32>

Source§

fn checked_ilog2(self) -> Option<u32>

Source§

fn checked_ilog10(self) -> Option<u32>

Source§

impl SignedInt for i128

Source§

type U = u128

Source§

fn checked_abs(self) -> Option<Self>

Source§

fn saturating_abs(self) -> Self

Source§

fn wrapping_abs(self) -> Self

Source§

fn overflowing_abs(self) -> (Self, bool)

Source§

fn unsigned_abs(self) -> Self::U

Source§

fn checked_neg(self) -> Option<Self>

Source§

fn saturating_neg(self) -> Self

Source§

fn wrapping_neg(self) -> Self

Source§

fn overflowing_neg(self) -> (Self, bool)

Source§

fn checked_add_unsigned(self, rhs: Self::U) -> Option<Self>

Source§

fn saturating_add_unsigned(self, rhs: Self::U) -> Self

Source§

fn wrapping_add_unsigned(self, rhs: Self::U) -> Self

Source§

fn overflowing_add_unsigned(self, rhs: Self::U) -> (Self, bool)

Source§

fn checked_sub_unsigned(self, rhs: Self::U) -> Option<Self>

Source§

fn saturating_sub_unsigned(self, rhs: Self::U) -> Self

Source§

fn wrapping_sub_unsigned(self, rhs: Self::U) -> Self

Source§

fn overflowing_sub_unsigned(self, rhs: Self::U) -> (Self, bool)

Source§

fn cast_unsigned(self) -> Self::U

Source§

fn signum(self) -> Self

Source§

fn isqrt(self) -> Self

Source§

fn checked_isqrt(self) -> Option<Self>

Source§

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

Source§

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

Source§

fn ilog(self, base: Self) -> u32

Source§

fn ilog2(self) -> u32

Source§

fn ilog10(self) -> u32

Source§

fn checked_ilog(self, base: Self) -> Option<u32>

Source§

fn checked_ilog2(self) -> Option<u32>

Source§

fn checked_ilog10(self) -> Option<u32>

Source§

impl SignedInt for isize

Source§

type U = usize

Source§

fn checked_abs(self) -> Option<Self>

Source§

fn saturating_abs(self) -> Self

Source§

fn wrapping_abs(self) -> Self

Source§

fn overflowing_abs(self) -> (Self, bool)

Source§

fn unsigned_abs(self) -> Self::U

Source§

fn checked_neg(self) -> Option<Self>

Source§

fn saturating_neg(self) -> Self

Source§

fn wrapping_neg(self) -> Self

Source§

fn overflowing_neg(self) -> (Self, bool)

Source§

fn checked_add_unsigned(self, rhs: Self::U) -> Option<Self>

Source§

fn saturating_add_unsigned(self, rhs: Self::U) -> Self

Source§

fn wrapping_add_unsigned(self, rhs: Self::U) -> Self

Source§

fn overflowing_add_unsigned(self, rhs: Self::U) -> (Self, bool)

Source§

fn checked_sub_unsigned(self, rhs: Self::U) -> Option<Self>

Source§

fn saturating_sub_unsigned(self, rhs: Self::U) -> Self

Source§

fn wrapping_sub_unsigned(self, rhs: Self::U) -> Self

Source§

fn overflowing_sub_unsigned(self, rhs: Self::U) -> (Self, bool)

Source§

fn cast_unsigned(self) -> Self::U

Source§

fn signum(self) -> Self

Source§

fn isqrt(self) -> Self

Source§

fn checked_isqrt(self) -> Option<Self>

Source§

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

Source§

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

Source§

fn ilog(self, base: Self) -> u32

Source§

fn ilog2(self) -> u32

Source§

fn ilog10(self) -> u32

Source§

fn checked_ilog(self, base: Self) -> Option<u32>

Source§

fn checked_ilog2(self) -> Option<u32>

Source§

fn checked_ilog10(self) -> Option<u32>

Implementors§