The signed integer type.
Methods
Raises self to the power of exp, using exponentiation by squaring.
Overflow behavior
This function will wrap on overflow.
Examples
Basic usage:
let x = 2;
assert_eq!;
Checked integer addition. Computes self + rhs, returning None if overflow occurred.
Examples
Basic usage:
assert_eq!;
assert_eq!;
Checked integer subtraction. Computes self - rhs, returning None if overflow occurred.
Examples
Basic usage:
assert_eq!;
assert_eq!;
Checked integer division. Computes self / rhs, returning None if rhs == 0 or the division results in overflow.
Examples
Basic usage:
assert_eq!;
assert_eq!;
assert_eq!;
Checked integer multiplication. Computes self * rhs, returning None if overflow occurred.
Examples
Basic usage:
assert_eq!;
assert_eq!;
Checked integer remainder. Computes self % rhs, returning None if rhs == 0 or the division results in overflow.
Examples
Basic usage:
assert_eq!;
assert_eq!;
assert_eq!;
Wrapping (modular) addition. Computes self + rhs, wrapping around at the boundary of the type.
Examples
Basic usage:
assert_eq!;
assert_eq!;
Wrapping (modular) subtraction. Computes self - rhs, wrapping around at the boundary of the type.
Examples
Basic usage:
assert_eq!;
assert_eq!;
Wrapping (modular) division. Computes self / rhs, wrapping around at the boundary of the type.
The only case where such wrapping can occur is when one divides MIN / -1 on a signed type (where MIN is the negative minimal value for the type); this is equivalent to -MIN, a positive value that is too large to represent in the type. In such a case, this function returns MIN itself.
Panics
This function will panic if rhs is 0.
Examples
Basic usage:
assert_eq!;
Wrapping (modular) multiplication. Computes self * rhs, wrapping around at the boundary of the type.
Examples
Basic usage:
assert_eq!;
Wrapping (modular) remainder. Computes self % rhs, wrapping around at the boundary of the type.
Such wrap-around never actually occurs mathematically; implementation artifacts make x % y invalid for MIN / -1 on a signed type (where MIN is the negative minimal value). In such a case, this function returns 0.
Panics
This function will panic if rhs is 0.
Examples
Basic usage:
assert_eq!;
Saturating integer addition. Computes self + rhs, saturating at the numeric bounds instead of overflowing.
Examples
Basic usage:
assert_eq!;
assert_eq!;
assert_eq!;
Saturating integer subtraction. Computes self - rhs, saturating at the numeric bounds instead of overflowing.
Examples
Basic usage:
assert_eq!;
assert_eq!;
assert_eq!;
Saturating integer multiplication. Computes self * rhs, saturating at the numeric bounds instead of overflowing.
Examples
Basic usage:
assert_eq!;
assert_eq!;
assert_eq!;
Saturating integer exponentiation. Computes self.pow(exp), saturating at the numeric bounds instead of overflowing.
Examples
Basic usage:
assert_eq!;
assert_eq!;
assert_eq!;
Returns the number as a string.
Examples
Basic usage:
assert_eq!;
assert_eq!;
Computes the absolute value of self.
Overflow behavior
The absolute value of i64::MIN cannot be represented as an int, and attempting to calculate it will cause an overflow. This means that such code will wrap to i64::MIN without a panic.
Examples
Basic usage:
assert_eq!;
assert_eq!;
Saturating absolute value. Computes self.abs(), returning MAX if self == MIN instead of overflowing.
Examples
Basic usage:
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
Returns a number representing sign of self.
0if the number is zero1if the number is positive-1if the number is negative
Examples
Basic usage:
assert_eq!;
assert_eq!;
assert_eq!;
Returns true if self is positive and false if the number is zero or negative.
Examples
Basic usage:
assert!;
assert!;
Returns true if self is negative and false if the number is zero or positive.
Examples
Basic usage:
assert!;
assert!;
Trait Implementations
Clone the specified value.
Examples
let a = 42;
let b = a;
let c = a.clone;
a += 1;
assert_eq!;
assert_eq!;
assert_eq!;
Compare two values for equality.
Examples
assert_eq!;
assert_eq!;
assert_eq!;
Compare two values for inequality.
Examples
assert_eq!;
assert_eq!;
assert_eq!;
Compare two values.
Examples
use Ordering;
assert_eq!;
assert_eq!;
assert_eq!;
Tests less than (for self and other) and is used by the < operator.
Examples
assert_eq!;
assert_eq!;
assert_eq!;
Tests less than or equal to (for self and other) and is used by the <= operator.
Examples
assert_eq!;
assert_eq!;
assert_eq!;
Tests greater than (for self and other) and is used by the > operator.
Examples
assert_eq!;
assert_eq!;
assert_eq!;
Tests greater than or equal to (for self and other) and is used by the >= operator.
Examples
assert_eq!;
assert_eq!;
assert_eq!;
Compare two values.
Examples
use Ordering;
assert_eq!;
assert_eq!;
assert_eq!;
Return the minimum of two values.
Examples
assert_eq!;
assert_eq!;
assert_eq!;
Return the maximum of two values.
Examples
assert_eq!;
assert_eq!;
assert_eq!;
Protocols
$a.max
Compares and returns the maximum of two values.
Returns the second argument if the comparison determines them to be equal.
Examples
assert_eq!;
assert_eq!;
$a.min
Compares and returns the minimum of two values.
Returns the first argument if the comparison determines them to be equal.
Examples
assert_eq!;
assert_eq!;
let $out = clone
Clone a i64.
Note that since the type is copy, cloning has the same effect as assigning it.
Examples
let a = 5i64;
let b = a;
let c = a.clone;
a += 1;
assert_eq!;
assert_eq!;
assert_eq!;
if value == b
Test two integers for partial equality.
Examples
assert_eq!;
assert_eq!;
assert_eq!;
if value == b
Test two integers for total equality.
Examples
use eq;
assert_eq!;
assert_eq!;
assert_eq!;
if value < b
Perform a partial ordered comparison between two integers.
Examples
use Ordering;
use partial_cmp;
assert_eq!;
assert_eq!;
assert_eq!;
if value < b
Perform a totally ordered comparison between two integers.
Examples
use Ordering;
use cmp;
assert_eq!;
assert_eq!;
assert_eq!;