Skip to main content

Int

Struct Int 

pub struct Int(IntInner);
Expand description

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

Tuple Fields§

§0: IntInner

Implementations§

§

impl Int

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

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

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 abs(self) -> Int

Computes the absolute value of self.

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

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

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

Raises self to the power of other.

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_ceil(self, other: impl Into<Int>) -> Int

Divides self by other and rounds up the result.

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

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

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

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

§

impl Int

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.

§

impl Int

pub const ZERO: Int

The number 0

pub const ONE: Int

The number 1

Trait Implementations§

§

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

§

type Output = Int

The resulting type after applying the + operator.
§

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

Performs the + operation. Read more
§

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

§

fn add_assign(&mut self, other: T)

Performs the += operation. Read more
§

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

§

type Output = Int

The resulting type after applying the & operator.
§

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

Performs the & operation. Read more
§

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

§

type Output = Int

The resulting type after applying the | operator.
§

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

Performs the | operation. Read more
§

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

§

type Output = Int

The resulting type after applying the ^ operator.
§

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

Performs the ^ operation. Read more
§

impl Clone for Int

§

fn clone(&self) -> Int

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
§

impl Copy for Int

§

impl Debug for Int

§

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

Formats the value using the given formatter. Read more
§

impl<'de> Deserialize<'de> for Int

§

fn deserialize<D>( deserializer: D, ) -> Result<Int, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
§

impl Display for Int

§

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

Formats the value using the given formatter. Read more
§

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

§

type Output = Int

The resulting type after applying the / operator.
§

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

Performs the / operation. Read more
§

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

§

fn div_assign(&mut self, other: T)

Performs the /= operation. Read more
§

impl Eq for Int

§

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

§

fn from(t: T) -> Int

Converts to this type from the input type.
§

impl Hash for Int

§

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

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
§

impl Mul<Int> for Size

§

type Output = Size

The resulting type after applying the * operator.
§

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

Performs the * operation. Read more
§

impl Mul<Size> for Int

§

type Output = Size

The resulting type after applying the * operator.
§

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

Performs the * operation. Read more
§

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

§

type Output = Int

The resulting type after applying the * operator.
§

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

Performs the * operation. Read more
§

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

§

fn mul_assign(&mut self, other: T)

Performs the *= operation. Read more
§

impl Neg for Int

§

type Output = Int

The resulting type after applying the - operator.
§

fn neg(self) -> Int

Performs the unary - operation. Read more
§

impl Not for Int

§

type Output = Int

The resulting type after applying the ! operator.
§

fn not(self) -> <Int as Not>::Output

Performs the unary ! operation. Read more
§

impl Ord for Int

§

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

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

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

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

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

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

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

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

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
§

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

§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
§

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

§

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 (const: unstable) · 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 (const: unstable) · 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 (const: unstable) · 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 (const: unstable) · 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
§

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

§

type Output = Int

The resulting type after applying the % operator.
§

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

Performs the % operation. Read more
§

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

§

fn rem_assign(&mut self, other: T)

Performs the %= operation. Read more
§

impl Serialize for Int

§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
§

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

§

type Output = Int

The resulting type after applying the << operator.
§

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

Performs the << operation. Read more
§

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

§

fn shl_assign(&mut self, other: T)

Performs the <<= operation. Read more
§

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

§

type Output = Int

The resulting type after applying the >> operator.
§

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

Performs the >> operation. Read more
§

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

§

fn shr_assign(&mut self, other: T)

Performs the >>= operation. Read more
§

impl Step for Int

§

fn steps_between(start: &Int, end: &Int) -> (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
§

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

🔬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
§

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

🔬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
§

fn forward_overflowing(start: Int, count: usize) -> (Int, bool)

🔬This is a nightly-only experimental API. (step_trait)
Returns the value that would be obtained by taking the successor of self count times along with a boolean tracking whether overflow occurred. Read more
§

fn backward_overflowing(start: Int, count: usize) -> (Int, bool)

🔬This is a nightly-only experimental API. (step_trait)
Returns the value that would be obtained by taking the successor of self count times along with a boolean tracking whether overflow occurred. 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
§

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

§

type Output = Int

The resulting type after applying the - operator.
§

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

Performs the - operation. Read more
§

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

§

fn sub_assign(&mut self, other: T)

Performs the -= operation. Read more

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> 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
§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<N> NodeTrait for N
where N: Copy + Ord + Hash,

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>,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more