Struct Int
pub struct Int(IntInner);Expand description
Garbage collected big integer that implements Copy and supports construction in const contexts.
Tuple Fields§
§0: IntInnerImplementations§
§impl Int
impl Int
pub fn is_power_of_two(self) -> bool
pub fn is_power_of_two(self) -> bool
Returns true if self is a power of two. false otherwise.
pub fn next_power_of_two(self) -> Int
pub fn next_power_of_two(self) -> Int
Returns the smallest power of two greater than or equal to self.
pub fn next_multiple_of(self, other: Int) -> Int
pub fn next_multiple_of(self, other: Int) -> Int
If other is positive, calculates the smallest value greater than or equal to self that is a multiple of other.
If other is negative, calculates the largest value less than or equal to self that is a multiple of other.
Panics if other is zero.
pub fn checked_div(self, other: Int) -> Option<Int>
pub fn checked_div(self, other: Int) -> Option<Int>
Checked integer division.
Returns None if and only if other == 0.
pub fn trailing_zeros(self) -> Option<Int>
pub fn trailing_zeros(self) -> Option<Int>
Returns the number of least-significant bits that are zero or None if the entire number is zero.
pub fn div_euclid(self, other: Int) -> Int
pub fn div_euclid(self, other: Int) -> Int
Calculates Euclidean division: the result is rounded towards -INF
for other > 0 and towards +INF for other < 0.
The result n satisfies self == n * other + self.rem_euclid(other).
pub fn rem_euclid(self, other: Int) -> Int
pub fn rem_euclid(self, other: Int) -> Int
Calculate nonnegative remainder of self (mod other).
The return value is in the range 0..other.abs().
pub fn bring_in_bounds(self, signed: Signedness, size: Size) -> Int
pub fn bring_in_bounds(self, signed: Signedness, size: Size) -> Int
Returns the unique value that is equal to self modulo 2^size.bits()
and within the bounds of a finite integer type with the given signedness and size.
If signed == Unsigned the result is in the interval 0..2^size.bits().
Otherwise it is in the interval -2^(size.bits()-1) .. 2^(size.bits()-1).
size must not be zero.
pub fn in_bounds(self, signed: Signedness, size: Size) -> bool
pub fn in_bounds(self, signed: Signedness, size: Size) -> bool
Tests whether an integer is in-bounds of a finite integer type.
Trait Implementations§
§impl<T> AddAssign<T> for Int
impl<T> AddAssign<T> for Int
§fn add_assign(&mut self, other: T)
fn add_assign(&mut self, other: T)
+= operation. Read moreimpl Copy for Int
§impl<'de> Deserialize<'de> for Int
impl<'de> Deserialize<'de> for Int
§fn deserialize<D>(
deserializer: D,
) -> Result<Int, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<Int, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
§impl<T> DivAssign<T> for Int
impl<T> DivAssign<T> for Int
§fn div_assign(&mut self, other: T)
fn div_assign(&mut self, other: T)
/= operation. Read moreimpl Eq for Int
§impl<T> MulAssign<T> for Int
impl<T> MulAssign<T> for Int
§fn mul_assign(&mut self, other: T)
fn mul_assign(&mut self, other: T)
*= operation. Read more§impl Ord for Int
impl Ord for Int
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
§impl<T> PartialOrd<T> for Int
impl<T> PartialOrd<T> for Int
§impl<T> RemAssign<T> for Int
impl<T> RemAssign<T> for Int
§fn rem_assign(&mut self, other: T)
fn rem_assign(&mut self, other: T)
%= operation. Read more§impl Serialize for Int
impl Serialize for Int
§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
§impl<T> ShlAssign<T> for Int
impl<T> ShlAssign<T> for Int
§fn shl_assign(&mut self, other: T)
fn shl_assign(&mut self, other: T)
<<= operation. Read more§impl<T> ShrAssign<T> for Int
impl<T> ShrAssign<T> for Int
§fn shr_assign(&mut self, other: T)
fn shr_assign(&mut self, other: T)
>>= operation. Read more§impl Step for Int
impl Step for Int
§fn steps_between(start: &Int, end: &Int) -> (usize, Option<usize>)
fn steps_between(start: &Int, end: &Int) -> (usize, Option<usize>)
step_trait)start to end
like Iterator::size_hint(). Read more§fn forward_checked(start: Int, count: usize) -> Option<Int>
fn forward_checked(start: Int, count: usize) -> Option<Int>
step_trait)§fn backward_checked(start: Int, count: usize) -> Option<Int>
fn backward_checked(start: Int, count: usize) -> Option<Int>
step_trait)§fn forward_overflowing(start: Int, count: usize) -> (Int, bool)
fn forward_overflowing(start: Int, count: usize) -> (Int, bool)
step_trait)self count times along with a boolean tracking whether overflow
occurred. Read more§fn backward_overflowing(start: Int, count: usize) -> (Int, bool)
fn backward_overflowing(start: Int, count: usize) -> (Int, bool)
step_trait)self count times along with a boolean tracking whether overflow
occurred. Read moreSource§fn forward(start: Self, count: usize) -> Self
fn forward(start: Self, count: usize) -> Self
step_trait)Source§unsafe fn forward_unchecked(start: Self, count: usize) -> Self
unsafe fn forward_unchecked(start: Self, count: usize) -> Self
step_trait)Source§fn backward(start: Self, count: usize) -> Self
fn backward(start: Self, count: usize) -> Self
step_trait)Source§unsafe fn backward_unchecked(start: Self, count: usize) -> Self
unsafe fn backward_unchecked(start: Self, count: usize) -> Self
step_trait)Auto Trait Implementations§
impl !Send for Int
impl !Sync for Int
impl Freeze for Int
impl RefUnwindSafe for Int
impl Unpin for Int
impl UnsafeUnpin for Int
impl UnwindSafe for Int
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more