Int

Struct Int 

Source
pub struct Int(/* private fields */);
Expand description

Garbage collected big integer that implements Copy and supports construction in const contexts.

Implementations§

Source§

impl Int

Source

pub fn is_power_of_two(self) -> bool

Returns true if self is a power of two. false otherwise.

Source

pub fn next_power_of_two(self) -> Int

Returns the smallest power of two greater than or equal to self.

Source

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.

Source

pub fn abs(self) -> Int

Computes the absolute value of self.

Source

pub fn checked_div(self, other: Int) -> Option<Int>

Checked integer division. Returns None if and only if other == 0.

Source

pub fn pow(self, other: Int) -> Int

Raises self to the power of other.

Source

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.

Source

pub fn div_ceil(self, other: impl Into<Int>) -> Int

Divides self by other and rounds up the result.

Source

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).

Source

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().

Source

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.

Source

pub fn in_bounds(self, signed: Signedness, size: Size) -> bool

Tests whether an integer is in-bounds of a finite integer type.

Source§

impl Int

Source

pub const fn from_u64(i: u64) -> Int

Create an Int from a regular Rust integer.

const fn cannot be generic but it turns out u64 is all we need.

Source§

impl Int

Source

pub const ZERO: Int

The number 0

Source

pub const ONE: Int

The number 1

Trait Implementations§

Source§

impl<T: Into<Int>> Add<T> for Int

Source§

type Output = Int

The resulting type after applying the + operator.
Source§

fn add(self, other: T) -> Self

Performs the + operation. Read more
Source§

impl<T: Into<Int>> AddAssign<T> for Int

Source§

fn add_assign(&mut self, other: T)

Performs the += operation. Read more
Source§

impl<T: Into<Int>> BitAnd<T> for Int

Source§

type Output = Int

The resulting type after applying the & operator.
Source§

fn bitand(self, other: T) -> Self

Performs the & operation. Read more
Source§

impl<T: Into<Int>> BitOr<T> for Int

Source§

type Output = Int

The resulting type after applying the | operator.
Source§

fn bitor(self, other: T) -> Self

Performs the | operation. Read more
Source§

impl<T: Into<Int>> BitXor<T> for Int

Source§

type Output = Int

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, other: T) -> Self

Performs the ^ operation. Read more
Source§

impl Clone for Int

Source§

fn clone(&self) -> Int

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Int

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Display for Int

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Distribution<Int> for IntDistribution

Source§

fn sample(&self, rng: &mut ThreadRng) -> Int

samples a value from the distribution.
Source§

impl<T: Into<Int>> Div<T> for Int

Source§

type Output = Int

The resulting type after applying the / operator.
Source§

fn div(self, other: T) -> Self

Performs the / operation. Read more
Source§

impl<T: Into<Int>> DivAssign<T> for Int

Source§

fn div_assign(&mut self, other: T)

Performs the /= operation. Read more
Source§

impl<T: ToInt> From<T> for Int

Source§

fn from(t: T) -> Int

Converts to this type from the input type.
Source§

impl Hash for Int

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Mul<Int> for Size

Source§

type Output = Size

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Int) -> Size

Performs the * operation. Read more
Source§

impl Mul<Size> for Int

Source§

type Output = Size

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Size) -> Size

Performs the * operation. Read more
Source§

impl<T: Into<Int>> Mul<T> for Int

Source§

type Output = Int

The resulting type after applying the * operator.
Source§

fn mul(self, other: T) -> Self

Performs the * operation. Read more
Source§

impl<T: Into<Int>> MulAssign<T> for Int

Source§

fn mul_assign(&mut self, other: T)

Performs the *= operation. Read more
Source§

impl Neg for Int

Source§

type Output = Int

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self

Performs the unary - operation. Read more
Source§

impl Not for Int

Source§

type Output = Int

The resulting type after applying the ! operator.
Source§

fn not(self) -> Self::Output

Performs the unary ! operation. Read more
Source§

impl Ord for Int

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<T: Into<Int> + Clone> PartialEq<T> for Int

Source§

fn eq(&self, other: &T) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: Into<Int> + Clone> PartialOrd<T> for Int

Source§

fn partial_cmp(&self, other: &T) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T: Into<Int>> Rem<T> for Int

Source§

type Output = Int

The resulting type after applying the % operator.
Source§

fn rem(self, other: T) -> Self

Performs the % operation. Read more
Source§

impl<T: Into<Int>> RemAssign<T> for Int

Source§

fn rem_assign(&mut self, other: T)

Performs the %= operation. Read more
Source§

impl<T: Into<Int>> Shl<T> for Int

Source§

type Output = Int

The resulting type after applying the << operator.
Source§

fn shl(self, other: T) -> Self

Performs the << operation. Read more
Source§

impl<T: Into<Int>> ShlAssign<T> for Int

Source§

fn shl_assign(&mut self, other: T)

Performs the <<= operation. Read more
Source§

impl<T: Into<Int>> Shr<T> for Int

Source§

type Output = Int

The resulting type after applying the >> operator.
Source§

fn shr(self, other: T) -> Self

Performs the >> operation. Read more
Source§

impl<T: Into<Int>> ShrAssign<T> for Int

Source§

fn shr_assign(&mut self, other: T)

Performs the >>= operation. Read more
Source§

impl Step for Int

Source§

fn steps_between(start: &Self, end: &Self) -> (usize, Option<usize>)

🔬This is a nightly-only experimental API. (step_trait)
Returns the bounds on the number of successor steps required to get from start to end like Iterator::size_hint(). Read more
Source§

fn forward_checked(start: Self, count: usize) -> Option<Self>

🔬This is a nightly-only experimental API. (step_trait)
Returns the value that would be obtained by taking the successor of self count times. Read more
Source§

fn backward_checked(start: Self, count: usize) -> Option<Self>

🔬This is a nightly-only experimental API. (step_trait)
Returns the value that would be obtained by taking the predecessor of self count times. Read more
Source§

fn forward(start: Self, count: usize) -> Self

🔬This is a nightly-only experimental API. (step_trait)
Returns the value that would be obtained by taking the successor of self count times. Read more
Source§

unsafe fn forward_unchecked(start: Self, count: usize) -> Self

🔬This is a nightly-only experimental API. (step_trait)
Returns the value that would be obtained by taking the successor of self count times. Read more
Source§

fn backward(start: Self, count: usize) -> Self

🔬This is a nightly-only experimental API. (step_trait)
Returns the value that would be obtained by taking the predecessor of self count times. Read more
Source§

unsafe fn backward_unchecked(start: Self, count: usize) -> Self

🔬This is a nightly-only experimental API. (step_trait)
Returns the value that would be obtained by taking the predecessor of self count times. Read more
Source§

impl<T: Into<Int>> Sub<T> for Int

Source§

type Output = Int

The resulting type after applying the - operator.
Source§

fn sub(self, other: T) -> Self

Performs the - operation. Read more
Source§

impl<T: Into<Int>> SubAssign<T> for Int

Source§

fn sub_assign(&mut self, other: T)

Performs the -= operation. Read more
Source§

impl Copy for Int

Source§

impl Eq for Int

Auto Trait Implementations§

§

impl Freeze for Int

§

impl RefUnwindSafe for Int

§

impl !Send for Int

§

impl !Sync for Int

§

impl Unpin for Int

§

impl UnwindSafe for Int

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T, Rhs> NumAssignOps<Rhs> for T
where T: AddAssign<Rhs> + SubAssign<Rhs> + MulAssign<Rhs> + DivAssign<Rhs> + RemAssign<Rhs>,

Source§

impl<T, Rhs, Output> NumOps<Rhs, Output> for T
where T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>,