pub struct Int { /* private fields */ }
Expand description
An arbitrary-precision signed integer.
This type grows to the size it needs to in order to store the result of any operation.
Creation
An Int
can be constructed in a number of ways:
-
Int::zero
andInt::one
construct a zero- and one-valuedInt
respectively. -
Int::from
will convert from any primitive integer type to anInt
of the same valuelet four = Int::from(4);
-
Int::from_str
(orstr::parse
) will attempt to convert from a string to anInt
let i = Int::from_str("123456789").unwrap();
Output
Int
supports all the formatting traits, allowing it to be used just like a regular integer
when used in format!
and similar macros. Int
also supports conversion to primitive integer
types, truncating if the Int
cannot fit into the target type. Conversion to primtive integers
is done with the From
trait:
let big_i = Int::from(123456789);
let i = i32::from(&big_i);
assert_eq!(123456789, i);
Usage
Int
has a number of operator overloads to make working with them as painless as possible.
The most basic usage is simply a + b
or similar. Assuming a
and b
are of type Int
, this
operation will consume both operands, reusing the storage from one of them. If you do not wish
your operands to be moved, one or both of them can be references: &a + &b
works as well, but
requires an entire new Int
to be allocated for the return value.
There are also a overloads for a small number of primitive integer types, namely i32
and
usize
. While automatic type widening isn’t done in Rust in general, many operations are much
more efficient when working with a single integer. This means you can do a + 1
knowing that it
will be performed as efficiently as possible. Comparison with these integer types is also
possible, allowing checks for small constant values to be done easily:
let big_i = Int::from(123456789);
assert!(big_i == 123456789);
Semantics
Addition, subtraction and multiplication follow the expected rules for integers. Division of two
integers, N / D
is defined as producing two values: a quotient, Q
, and a remainder, R
,
such that the following equation holds: N = Q*D + R
. The division operator itself returns Q
while the remainder/modulo operator returns R
. The sign of R
is the same as the sign of Q
.
The “bit-shift” operations are defined as being multiplication and division by a power-of-two for shift-left and shift-right respectively. The sign of the number is unaffected.
The remaining bitwise operands act as if the numbers are stored in two’s complement format and as if the two inputs have the same number of bits.
Implementations
sourceimpl Int
impl Int
sourcepub fn from_single_limb(limb: Limb) -> Int
pub fn from_single_limb(limb: Limb) -> Int
Creates an Int
from a single Limb
sourcepub fn sign(&self) -> i32
pub fn sign(&self) -> i32
Returns the sign of this Int
as either -1, 0 or 1 depending on whether it is negative,
zero, or positive, respectively.
sourcepub fn to_single_limb(&self) -> Limb
pub fn to_single_limb(&self) -> Limb
Returns the least-significant Limb
of this Int
.
sourcepub fn abs_cmp(&self, other: &Int) -> Ordering
pub fn abs_cmp(&self, other: &Int) -> Ordering
Compares the absolute value of this Int
with the absolute value of another.
sourcepub fn abs_eq(&self, other: &Int) -> bool
pub fn abs_eq(&self, other: &Int) -> bool
Returns whether this Int
has the same absolute value as another.
sourcepub fn abs_hash<H>(&self, state: &mut H) where
H: Hasher,
pub fn abs_hash<H>(&self, state: &mut H) where
H: Hasher,
Hashes the value without including the sign.
This is useful for when the sign is handled elsewhere and making a copy just to change the sign is wasteful.
sourcepub fn shrink_to_fit(&mut self)
pub fn shrink_to_fit(&mut self)
Shrinks the allocated data for this Int
, attempting to remove excess capacity.
sourcepub fn to_str_radix(&self, base: u8, upper: bool) -> String
pub fn to_str_radix(&self, base: u8, upper: bool) -> String
Creates a string containing the value of this Int
in base base
.
For bases greater than ten, if upper
is true, upper-case letters are used; otherwise,
lower-case letters are used.
Panics
Panics if base
is less than two or greater than 36.
sourcepub fn write_radix<W: Write>(
&self,
w: &mut W,
base: u8,
upper: bool
) -> Result<()>
pub fn write_radix<W: Write>(
&self,
w: &mut W,
base: u8,
upper: bool
) -> Result<()>
Similar to to_str_radix
, writing to something that implements io::Write
instead.
sourcepub fn from_str_radix(src: &str, base: u8) -> Result<Int, ParseIntError>
pub fn from_str_radix(src: &str, base: u8) -> Result<Int, ParseIntError>
Creates a new Int from the given string in base base
.
sourcepub fn divmod(&self, other: &Int) -> (Int, Int)
pub fn divmod(&self, other: &Int) -> (Int, Int)
Divides this Int
by other
, returning the quotient q
and the remainder r
as (q, r)
.
This satisfies self = q * other + r
, ensuring that q
and r
have the same sign.
Panics
Panics if other
is zero.
sourcepub fn pow_mod(&self, exp: &Int, modulus: &Int) -> Int
pub fn pow_mod(&self, exp: &Int, modulus: &Int) -> Int
Raises this Int
to the power exp
, all modulo modulus
. 0^0 mod m = 1 mod m
Panics
Panics if exp
is negative or modulus
is zero.
sourcepub fn dsquare(self) -> Int
pub fn dsquare(self) -> Int
Consumes this Int
and returns its square.
TODO: Is there a more idiomatic way of doing this?
sourcepub fn sqrt_rem(self) -> Option<(Int, Int)>
pub fn sqrt_rem(self) -> Option<(Int, Int)>
Computes the nearest square root s
of this number and its remainder r
as
Some((s, r))
, or None
if this Int
is negative.
s
and r
are both positive and satisfy self = s * s + r
.
sourcepub fn trailing_zeros(&self) -> u32
pub fn trailing_zeros(&self) -> u32
Returns the number of trailing zero bits for this Int
, or zero if this Int
is zero.
sourcepub fn count_ones(&self) -> usize
pub fn count_ones(&self) -> usize
Returns the number of one bits (i.e. the population count) for this Int
If this number is negative, it has infinitely many ones (in two’s complement). Therefore,
this method returns usize::MAX
for negative numbers.
sourcepub fn bit_length(&self) -> u32
pub fn bit_length(&self) -> u32
Returns the number of bits required to represent the absolute value of this Int
, i.e.,
floor(log2(abs(self))) + 1
.
Returns one if this number is zero.
sourcepub fn bit(&self, bit: u32) -> bool
pub fn bit(&self, bit: u32) -> bool
Returns the value of the bit
th bit in this Int
, as if it were represented in two’s
complement.
sourcepub fn set_bit(&mut self, bit: u32, bit_val: bool)
pub fn set_bit(&mut self, bit: u32, bit_val: bool)
Sets the bit
th bit of this number to bit_val
, treating negative numbers as if they’re
stored in two’s complement.
sourcepub fn gcd(&self, other: &Int) -> Int
pub fn gcd(&self, other: &Int) -> Int
Computes the greates common divisor (GCD) of this Int
and other
.
The result is always positive.
Trait Implementations
sourceimpl<'a> AddAssign<&'a Int> for Int
impl<'a> AddAssign<&'a Int> for Int
sourcefn add_assign(&mut self, other: &'a Int)
fn add_assign(&mut self, other: &'a Int)
Performs the +=
operation. Read more
sourceimpl<'a> AddAssign<&'a Int> for Rational
impl<'a> AddAssign<&'a Int> for Rational
sourcefn add_assign(&mut self, other: &'a Int)
fn add_assign(&mut self, other: &'a Int)
Performs the +=
operation. Read more
sourceimpl AddAssign<Int> for Int
impl AddAssign<Int> for Int
sourcefn add_assign(&mut self, other: Int)
fn add_assign(&mut self, other: Int)
Performs the +=
operation. Read more
sourceimpl AddAssign<Int> for Rational
impl AddAssign<Int> for Rational
sourcefn add_assign(&mut self, other: Int)
fn add_assign(&mut self, other: Int)
Performs the +=
operation. Read more
sourceimpl AddAssign<Limb> for Int
impl AddAssign<Limb> for Int
sourcefn add_assign(&mut self, other: Limb)
fn add_assign(&mut self, other: Limb)
Performs the +=
operation. Read more
sourceimpl AddAssign<i32> for Int
impl AddAssign<i32> for Int
sourcefn add_assign(&mut self, other: i32)
fn add_assign(&mut self, other: i32)
Performs the +=
operation. Read more
sourceimpl AddAssign<u64> for Int
impl AddAssign<u64> for Int
sourcefn add_assign(&mut self, other: BaseInt)
fn add_assign(&mut self, other: BaseInt)
Performs the +=
operation. Read more
sourceimpl AddAssign<usize> for Int
impl AddAssign<usize> for Int
sourcefn add_assign(&mut self, other: usize)
fn add_assign(&mut self, other: usize)
Performs the +=
operation. Read more
sourceimpl<'a> BitAndAssign<&'a Int> for Int
impl<'a> BitAndAssign<&'a Int> for Int
sourcefn bitand_assign(&mut self, other: &'a Int)
fn bitand_assign(&mut self, other: &'a Int)
Performs the &=
operation. Read more
sourceimpl BitAndAssign<Int> for Int
impl BitAndAssign<Int> for Int
sourcefn bitand_assign(&mut self, other: Int)
fn bitand_assign(&mut self, other: Int)
Performs the &=
operation. Read more
sourceimpl BitAndAssign<Limb> for Int
impl BitAndAssign<Limb> for Int
sourcefn bitand_assign(&mut self, other: Limb)
fn bitand_assign(&mut self, other: Limb)
Performs the &=
operation. Read more
sourceimpl BitAndAssign<i32> for Int
impl BitAndAssign<i32> for Int
sourcefn bitand_assign(&mut self, other: i32)
fn bitand_assign(&mut self, other: i32)
Performs the &=
operation. Read more
sourceimpl BitAndAssign<u64> for Int
impl BitAndAssign<u64> for Int
sourcefn bitand_assign(&mut self, other: BaseInt)
fn bitand_assign(&mut self, other: BaseInt)
Performs the &=
operation. Read more
sourceimpl BitAndAssign<usize> for Int
impl BitAndAssign<usize> for Int
sourcefn bitand_assign(&mut self, other: usize)
fn bitand_assign(&mut self, other: usize)
Performs the &=
operation. Read more
sourceimpl<'a> BitOrAssign<&'a Int> for Int
impl<'a> BitOrAssign<&'a Int> for Int
sourcefn bitor_assign(&mut self, other: &'a Int)
fn bitor_assign(&mut self, other: &'a Int)
Performs the |=
operation. Read more
sourceimpl BitOrAssign<Int> for Int
impl BitOrAssign<Int> for Int
sourcefn bitor_assign(&mut self, other: Int)
fn bitor_assign(&mut self, other: Int)
Performs the |=
operation. Read more
sourceimpl BitOrAssign<Limb> for Int
impl BitOrAssign<Limb> for Int
sourcefn bitor_assign(&mut self, other: Limb)
fn bitor_assign(&mut self, other: Limb)
Performs the |=
operation. Read more
sourceimpl BitOrAssign<i32> for Int
impl BitOrAssign<i32> for Int
sourcefn bitor_assign(&mut self, other: i32)
fn bitor_assign(&mut self, other: i32)
Performs the |=
operation. Read more
sourceimpl BitOrAssign<u64> for Int
impl BitOrAssign<u64> for Int
sourcefn bitor_assign(&mut self, other: BaseInt)
fn bitor_assign(&mut self, other: BaseInt)
Performs the |=
operation. Read more
sourceimpl BitOrAssign<usize> for Int
impl BitOrAssign<usize> for Int
sourcefn bitor_assign(&mut self, other: usize)
fn bitor_assign(&mut self, other: usize)
Performs the |=
operation. Read more
sourceimpl<'a> BitXorAssign<&'a Int> for Int
impl<'a> BitXorAssign<&'a Int> for Int
sourcefn bitxor_assign(&mut self, other: &'a Int)
fn bitxor_assign(&mut self, other: &'a Int)
Performs the ^=
operation. Read more
sourceimpl BitXorAssign<Int> for Int
impl BitXorAssign<Int> for Int
sourcefn bitxor_assign(&mut self, other: Int)
fn bitxor_assign(&mut self, other: Int)
Performs the ^=
operation. Read more
sourceimpl BitXorAssign<Limb> for Int
impl BitXorAssign<Limb> for Int
sourcefn bitxor_assign(&mut self, other: Limb)
fn bitxor_assign(&mut self, other: Limb)
Performs the ^=
operation. Read more
sourceimpl BitXorAssign<i32> for Int
impl BitXorAssign<i32> for Int
sourcefn bitxor_assign(&mut self, other: i32)
fn bitxor_assign(&mut self, other: i32)
Performs the ^=
operation. Read more
sourceimpl BitXorAssign<u64> for Int
impl BitXorAssign<u64> for Int
sourcefn bitxor_assign(&mut self, other: BaseInt)
fn bitxor_assign(&mut self, other: BaseInt)
Performs the ^=
operation. Read more
sourceimpl BitXorAssign<usize> for Int
impl BitXorAssign<usize> for Int
sourcefn bitxor_assign(&mut self, other: usize)
fn bitxor_assign(&mut self, other: usize)
Performs the ^=
operation. Read more
sourceimpl<'a> DivAssign<&'a Int> for Int
impl<'a> DivAssign<&'a Int> for Int
sourcefn div_assign(&mut self, other: &'a Int)
fn div_assign(&mut self, other: &'a Int)
Performs the /=
operation. Read more
sourceimpl<'a> DivAssign<&'a Int> for Rational
impl<'a> DivAssign<&'a Int> for Rational
sourcefn div_assign(&mut self, other: &'a Int)
fn div_assign(&mut self, other: &'a Int)
Performs the /=
operation. Read more
sourceimpl DivAssign<Int> for Int
impl DivAssign<Int> for Int
sourcefn div_assign(&mut self, other: Int)
fn div_assign(&mut self, other: Int)
Performs the /=
operation. Read more
sourceimpl DivAssign<Int> for Rational
impl DivAssign<Int> for Rational
sourcefn div_assign(&mut self, other: Int)
fn div_assign(&mut self, other: Int)
Performs the /=
operation. Read more
sourceimpl DivAssign<Limb> for Int
impl DivAssign<Limb> for Int
sourcefn div_assign(&mut self, other: Limb)
fn div_assign(&mut self, other: Limb)
Performs the /=
operation. Read more
sourceimpl DivAssign<i32> for Int
impl DivAssign<i32> for Int
sourcefn div_assign(&mut self, other: i32)
fn div_assign(&mut self, other: i32)
Performs the /=
operation. Read more
sourceimpl DivAssign<u64> for Int
impl DivAssign<u64> for Int
sourcefn div_assign(&mut self, other: BaseInt)
fn div_assign(&mut self, other: BaseInt)
Performs the /=
operation. Read more
sourceimpl DivAssign<usize> for Int
impl DivAssign<usize> for Int
sourcefn div_assign(&mut self, other: usize)
fn div_assign(&mut self, other: usize)
Performs the /=
operation. Read more
sourceimpl FromStr for Int
impl FromStr for Int
type Err = ParseIntError
type Err = ParseIntError
The associated error which can be returned from parsing.
sourceimpl Integer for Int
impl Integer for Int
sourcefn is_multiple_of(&self, other: &Int) -> bool
fn is_multiple_of(&self, other: &Int) -> bool
Returns true
if self
is a multiple of other
. Read more
sourcefn div_rem(&self, other: &Int) -> (Int, Int)
fn div_rem(&self, other: &Int) -> (Int, Int)
Simultaneous truncated integer division and modulus.
Returns (quotient, remainder)
. Read more
sourcefn gcd_lcm(&self, other: &Self) -> (Self, Self)
fn gcd_lcm(&self, other: &Self) -> (Self, Self)
Greatest Common Divisor (GCD) and Lowest Common Multiple (LCM) together. Read more
sourcefn extended_gcd(&self, other: &Self) -> ExtendedGcd<Self> where
Self: Clone,
fn extended_gcd(&self, other: &Self) -> ExtendedGcd<Self> where
Self: Clone,
Greatest common divisor and Bézout coefficients. Read more
sourcefn extended_gcd_lcm(&self, other: &Self) -> (ExtendedGcd<Self>, Self) where
Self: Clone + Signed,
fn extended_gcd_lcm(&self, other: &Self) -> (ExtendedGcd<Self>, Self) where
Self: Clone + Signed,
Greatest common divisor, least common multiple, and Bézout coefficients.
sourcefn div_mod_floor(&self, other: &Self) -> (Self, Self)
fn div_mod_floor(&self, other: &Self) -> (Self, Self)
Simultaneous floored integer division and modulus.
Returns (quotient, remainder)
. Read more
sourcefn next_multiple_of(&self, other: &Self) -> Self where
Self: Clone,
fn next_multiple_of(&self, other: &Self) -> Self where
Self: Clone,
Rounds up to nearest multiple of argument. Read more
sourcefn prev_multiple_of(&self, other: &Self) -> Self where
Self: Clone,
fn prev_multiple_of(&self, other: &Self) -> Self where
Self: Clone,
Rounds down to nearest multiple of argument. Read more
sourceimpl<'a> MulAssign<&'a Int> for Int
impl<'a> MulAssign<&'a Int> for Int
sourcefn mul_assign(&mut self, other: &'a Int)
fn mul_assign(&mut self, other: &'a Int)
Performs the *=
operation. Read more
sourceimpl<'a> MulAssign<&'a Int> for Rational
impl<'a> MulAssign<&'a Int> for Rational
sourcefn mul_assign(&mut self, other: &'a Int)
fn mul_assign(&mut self, other: &'a Int)
Performs the *=
operation. Read more
sourceimpl MulAssign<Int> for Int
impl MulAssign<Int> for Int
sourcefn mul_assign(&mut self, other: Int)
fn mul_assign(&mut self, other: Int)
Performs the *=
operation. Read more
sourceimpl MulAssign<Int> for Rational
impl MulAssign<Int> for Rational
sourcefn mul_assign(&mut self, other: Int)
fn mul_assign(&mut self, other: Int)
Performs the *=
operation. Read more
sourceimpl MulAssign<Limb> for Int
impl MulAssign<Limb> for Int
sourcefn mul_assign(&mut self, other: Limb)
fn mul_assign(&mut self, other: Limb)
Performs the *=
operation. Read more
sourceimpl MulAssign<i32> for Int
impl MulAssign<i32> for Int
sourcefn mul_assign(&mut self, other: i32)
fn mul_assign(&mut self, other: i32)
Performs the *=
operation. Read more
sourceimpl MulAssign<u64> for Int
impl MulAssign<u64> for Int
sourcefn mul_assign(&mut self, other: BaseInt)
fn mul_assign(&mut self, other: BaseInt)
Performs the *=
operation. Read more
sourceimpl MulAssign<usize> for Int
impl MulAssign<usize> for Int
sourcefn mul_assign(&mut self, other: usize)
fn mul_assign(&mut self, other: usize)
Performs the *=
operation. Read more
sourceimpl Num for Int
impl Num for Int
type FromStrRadixErr = ParseIntError
sourcefn from_str_radix(src: &str, radix: u32) -> Result<Int, ParseIntError>
fn from_str_radix(src: &str, radix: u32) -> Result<Int, ParseIntError>
Convert from a string and radix (typically 2..=36
). Read more
sourceimpl Ord for Int
impl Ord for Int
sourceimpl PartialOrd<Int> for Int
impl PartialOrd<Int> for Int
sourcefn partial_cmp(&self, other: &Int) -> Option<Ordering>
fn partial_cmp(&self, other: &Int) -> 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 PartialOrd<Int> for Limb
impl PartialOrd<Int> for Limb
sourcefn partial_cmp(&self, other: &Int) -> Option<Ordering>
fn partial_cmp(&self, other: &Int) -> 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 PartialOrd<Int> for i32
impl PartialOrd<Int> for i32
sourcefn partial_cmp(&self, other: &Int) -> Option<Ordering>
fn partial_cmp(&self, other: &Int) -> 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 PartialOrd<Int> for usize
impl PartialOrd<Int> for usize
sourcefn partial_cmp(&self, other: &Int) -> Option<Ordering>
fn partial_cmp(&self, other: &Int) -> 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 PartialOrd<Int> for u64
impl PartialOrd<Int> for u64
sourcefn partial_cmp(&self, other: &Int) -> Option<Ordering>
fn partial_cmp(&self, other: &Int) -> 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 PartialOrd<Int> for i64
impl PartialOrd<Int> for i64
sourcefn partial_cmp(&self, other: &Int) -> Option<Ordering>
fn partial_cmp(&self, other: &Int) -> 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 PartialOrd<Int> for Rational
impl PartialOrd<Int> for Rational
sourcefn partial_cmp(&self, other: &Int) -> Option<Ordering>
fn partial_cmp(&self, other: &Int) -> 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 PartialOrd<Limb> for Int
impl PartialOrd<Limb> for Int
sourcefn partial_cmp(&self, other: &Limb) -> Option<Ordering>
fn partial_cmp(&self, other: &Limb) -> 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 PartialOrd<Rational> for Int
impl PartialOrd<Rational> for Int
sourcefn partial_cmp(&self, other: &Rational) -> Option<Ordering>
fn partial_cmp(&self, other: &Rational) -> 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 PartialOrd<i32> for Int
impl PartialOrd<i32> for Int
sourcefn partial_cmp(&self, other: &i32) -> Option<Ordering>
fn partial_cmp(&self, other: &i32) -> 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 PartialOrd<i64> for Int
impl PartialOrd<i64> for Int
sourcefn partial_cmp(&self, other: &i64) -> Option<Ordering>
fn partial_cmp(&self, other: &i64) -> 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 PartialOrd<u64> for Int
impl PartialOrd<u64> for Int
sourcefn partial_cmp(&self, other: &u64) -> Option<Ordering>
fn partial_cmp(&self, other: &u64) -> 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 PartialOrd<usize> for Int
impl PartialOrd<usize> for Int
sourcefn partial_cmp(&self, other: &usize) -> Option<Ordering>
fn partial_cmp(&self, other: &usize) -> 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<'a> RemAssign<&'a Int> for Int
impl<'a> RemAssign<&'a Int> for Int
sourcefn rem_assign(&mut self, other: &'a Int)
fn rem_assign(&mut self, other: &'a Int)
Performs the %=
operation. Read more
sourceimpl RemAssign<Int> for Int
impl RemAssign<Int> for Int
sourcefn rem_assign(&mut self, other: Int)
fn rem_assign(&mut self, other: Int)
Performs the %=
operation. Read more
sourceimpl RemAssign<Limb> for Int
impl RemAssign<Limb> for Int
sourcefn rem_assign(&mut self, other: Limb)
fn rem_assign(&mut self, other: Limb)
Performs the %=
operation. Read more
sourceimpl RemAssign<i32> for Int
impl RemAssign<i32> for Int
sourcefn rem_assign(&mut self, other: i32)
fn rem_assign(&mut self, other: i32)
Performs the %=
operation. Read more
sourceimpl RemAssign<u64> for Int
impl RemAssign<u64> for Int
sourcefn rem_assign(&mut self, other: BaseInt)
fn rem_assign(&mut self, other: BaseInt)
Performs the %=
operation. Read more
sourceimpl RemAssign<usize> for Int
impl RemAssign<usize> for Int
sourcefn rem_assign(&mut self, other: usize)
fn rem_assign(&mut self, other: usize)
Performs the %=
operation. Read more
sourceimpl ShlAssign<usize> for Int
impl ShlAssign<usize> for Int
sourcefn shl_assign(&mut self, cnt: usize)
fn shl_assign(&mut self, cnt: usize)
Performs the <<=
operation. Read more
sourceimpl ShrAssign<usize> for Int
impl ShrAssign<usize> for Int
sourcefn shr_assign(&mut self, cnt: usize)
fn shr_assign(&mut self, cnt: usize)
Performs the >>=
operation. Read more
sourceimpl Step for Int
impl Step for Int
sourcefn steps_between(start: &Int, end: &Int) -> Option<usize>
fn steps_between(start: &Int, end: &Int) -> Option<usize>
step_trait
)Returns the number of successor steps required to get from start
to end
. Read more
sourcefn forward_checked(start: Int, n: usize) -> Option<Self>
fn forward_checked(start: Int, n: usize) -> Option<Self>
step_trait
)Returns the value that would be obtained by taking the successor
of self
count
times. Read more
sourcefn backward_checked(start: Int, n: usize) -> Option<Self>
fn backward_checked(start: Int, n: usize) -> Option<Self>
step_trait
)Returns the value that would be obtained by taking the predecessor
of self
count
times. Read more
sourcefn forward(start: Self, count: usize) -> Self
fn forward(start: Self, count: usize) -> Self
step_trait
)Returns the value that would be obtained by taking the successor
of self
count
times. Read more
sourceunsafe fn forward_unchecked(start: Self, count: usize) -> Self
unsafe fn forward_unchecked(start: Self, count: usize) -> Self
step_trait
)Returns the value that would be obtained by taking the successor
of self
count
times. Read more
sourcefn backward(start: Self, count: usize) -> Self
fn backward(start: Self, count: usize) -> Self
step_trait
)Returns the value that would be obtained by taking the predecessor
of self
count
times. Read more
sourceunsafe fn backward_unchecked(start: Self, count: usize) -> Self
unsafe fn backward_unchecked(start: Self, count: usize) -> Self
step_trait
)Returns the value that would be obtained by taking the predecessor
of self
count
times. Read more
sourceimpl<'a> SubAssign<&'a Int> for Int
impl<'a> SubAssign<&'a Int> for Int
sourcefn sub_assign(&mut self, other: &'a Int)
fn sub_assign(&mut self, other: &'a Int)
Performs the -=
operation. Read more
sourceimpl SubAssign<Int> for Int
impl SubAssign<Int> for Int
sourcefn sub_assign(&mut self, other: Int)
fn sub_assign(&mut self, other: Int)
Performs the -=
operation. Read more
sourceimpl SubAssign<Limb> for Int
impl SubAssign<Limb> for Int
sourcefn sub_assign(&mut self, other: Limb)
fn sub_assign(&mut self, other: Limb)
Performs the -=
operation. Read more
sourceimpl SubAssign<i32> for Int
impl SubAssign<i32> for Int
sourcefn sub_assign(&mut self, other: i32)
fn sub_assign(&mut self, other: i32)
Performs the -=
operation. Read more
sourceimpl SubAssign<u64> for Int
impl SubAssign<u64> for Int
sourcefn sub_assign(&mut self, other: BaseInt)
fn sub_assign(&mut self, other: BaseInt)
Performs the -=
operation. Read more
sourceimpl SubAssign<usize> for Int
impl SubAssign<usize> for Int
sourcefn sub_assign(&mut self, other: usize)
fn sub_assign(&mut self, other: usize)
Performs the -=
operation. Read more
impl Eq for Int
Auto Trait Implementations
impl RefUnwindSafe for Int
impl Send for Int
impl Sync for Int
impl Unpin for Int
impl UnwindSafe for Int
Blanket Implementations
sourceimpl<I> Average for I where
I: Integer + Shr<usize, Output = I>,
&'a I: for<'a, 'b> BitAnd<&'b I>,
&'a I: for<'a, 'b> BitOr<&'b I>,
&'a I: for<'a, 'b> BitXor<&'b I>,
<&'a I as BitAnd<&'b I>>::Output == I,
<&'a I as BitOr<&'b I>>::Output == I,
<&'a I as BitXor<&'b I>>::Output == I,
impl<I> Average for I where
I: Integer + Shr<usize, Output = I>,
&'a I: for<'a, 'b> BitAnd<&'b I>,
&'a I: for<'a, 'b> BitOr<&'b I>,
&'a I: for<'a, 'b> BitXor<&'b I>,
<&'a I as BitAnd<&'b I>>::Output == I,
<&'a I as BitOr<&'b I>>::Output == I,
<&'a I as BitXor<&'b I>>::Output == I,
sourcefn average_floor(&self, other: &I) -> I
fn average_floor(&self, other: &I) -> I
Returns the floor value of the average of self
and other
.
sourcefn average_ceil(&self, other: &I) -> I
fn average_ceil(&self, other: &I) -> I
Returns the ceil value of the average of self
and other
.
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
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more