Trait num_traits::Int
[−]
[src]
pub trait Int: Copy + Clone + PartialOrd + PartialEq + Zero + One + Add<Output=Self> + Sub<Output=Self> + Mul<Output=Self> + Div<Output=Self> + Rem<Output=Self> + Not<Output=Self> + BitAnd<Output=Self> + BitOr<Output=Self> + BitXor<Output=Self> + Shl<usize, Output=Self> + Shr<usize, Output=Self> {
fn min_value() -> Self;
fn max_value() -> Self;
fn from_str_radix(src: &str, radix: u32) -> Result<Self, ParseIntError>;
fn count_ones(self) -> u32;
fn count_zeros(self) -> u32;
fn leading_zeros(self) -> u32;
fn trailing_zeros(self) -> u32;
fn rotate_left(self, n: u32) -> Self;
fn rotate_right(self, n: u32) -> Self;
fn swap_bytes(self) -> Self;
fn from_be(x: Self) -> Self;
fn from_le(x: Self) -> Self;
fn to_be(self) -> Self;
fn to_le(self) -> Self;
fn checked_add(self, other: Self) -> Option<Self>;
fn checked_sub(self, other: Self) -> Option<Self>;
fn checked_mul(self, other: Self) -> Option<Self>;
fn checked_div(self, other: Self) -> Option<Self>;
fn saturating_add(self, other: Self) -> Self;
fn saturating_sub(self, other: Self) -> Self;
fn wrapping_add(self, rhs: Self) -> Self;
fn wrapping_sub(self, rhs: Self) -> Self;
fn wrapping_mul(self, rhs: Self) -> Self;
fn wrapping_div(self, rhs: Self) -> Self;
fn wrapping_rem(self, rhs: Self) -> Self;
fn wrapping_neg(self) -> Self;
fn wrapping_shl(self, rhs: u32) -> Self;
fn wrapping_shr(self, rhs: u32) -> Self;
fn pow(self, exp: u32) -> Self;
}Signed and unsigned integers.
Required Methods
fn min_value() -> Self
Returns the smallest value that can be represented by this numeric type.
fn max_value() -> Self
Returns the largest value that can be represented by this numeric type.
fn from_str_radix(src: &str, radix: u32) -> Result<Self, ParseIntError>
Converts a string slice in a given base to an integer.
fn count_ones(self) -> u32
Returns the number of ones in the binary representation of self.
fn count_zeros(self) -> u32
Returns the number of zeros in the binary representation of self.
fn leading_zeros(self) -> u32
Returns the number of leading zeros in the binary representation of self.
fn trailing_zeros(self) -> u32
Returns the number of trailing zeros in the binary representation of self.
fn rotate_left(self, n: u32) -> Self
Shifts the bits to the left by a specified amount, n,
wrapping the truncated bits to the end of the resulting integer.
fn rotate_right(self, n: u32) -> Self
Shifts the bits to the right by a specified amount, n,
wrapping the truncated bits to the beginning of the resulting integer.
fn swap_bytes(self) -> Self
Reverses the byte order of the integer.
fn from_be(x: Self) -> Self
Converts an integer from big endian to the target's endianness.
fn from_le(x: Self) -> Self
Converts an integer from little endian to the target's endianness.
fn to_be(self) -> Self
Converts self to big endian from the target's endianness.
fn to_le(self) -> Self
Converts self to little endian from the target's endianness.
fn checked_add(self, other: Self) -> Option<Self>
Checked integer addition. Computes self + other,
returning None if overflow occurred.
fn checked_sub(self, other: Self) -> Option<Self>
Checked integer subtraction. Computes self - other,
returning None if underflow occurred.
fn checked_mul(self, other: Self) -> Option<Self>
Checked integer multiplication. Computes self * other,
returning None if underflow or overflow occurred.
fn checked_div(self, other: Self) -> Option<Self>
Checked integer division. Computes self / other,
returning None if other == 0 or the operation results in underflow or overflow.
fn saturating_add(self, other: Self) -> Self
Saturating integer addition. Computes self + other,
saturating at the numeric bounds instead of overflowing.
fn saturating_sub(self, other: Self) -> Self
Saturating integer subtraction. Computes self - other,
saturating at the numeric bounds instead of overflowing.
fn wrapping_add(self, rhs: Self) -> Self
Wrapping (modular) addition. Computes self + other,
wrapping around at the boundary of the type.
fn wrapping_sub(self, rhs: Self) -> Self
Wrapping (modular) subtraction. Computes self - other,
wrapping around at the boundary of the type.
fn wrapping_mul(self, rhs: Self) -> Self
Wrapping (modular) multiplication. Computes self * other,
wrapping around at the boundary of the type.
fn wrapping_div(self, rhs: Self) -> Self
Wrapping (modular) division. Computes self / other,
wrapping around at the boundary of the type.
fn wrapping_rem(self, rhs: Self) -> Self
Wrapping (modular) remainder. Computes self % other,
wrapping around at the boundary of the type.
fn wrapping_neg(self) -> Self
Wrapping (modular) negation. Computes `-self,
wrapping around at the boundary of the type.
fn wrapping_shl(self, rhs: u32) -> Self
Panic-free bitwise shift-left; yields self << mask(rhs),
where mask removes any high-order bits of rhs that would
cause the shift to exceed the bitwidth of the type.
fn wrapping_shr(self, rhs: u32) -> Self
Panic-free bitwise shift-left; yields self >> mask(rhs),
where mask removes any high-order bits of rhs that would
cause the shift to exceed the bitwidth of the type.
fn pow(self, exp: u32) -> Self
Raises self to the power of exp, using exponentiation by squaring.