Struct libspecr::Int

source ·
pub struct Int(_);
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 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 modulo(self, signed: Signedness, size: Size) -> Int

Returns the unique value that is equal to self modulo 2^size.bits(). If signed == Unsigned, the result is in the interval 0..2^size.bits(), else 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 ZERO: Int = _

The number 0

source

pub const ONE: Int = _

The number 1

Trait Implementations§

source§

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

§

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

§

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

§

type Output = Int

The resulting type after applying the | operator.
source§

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

Performs the | operation. Read more
source§

impl Clone for Int

source§

fn clone(&self) -> Int

Returns a copy 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

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

§

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§

const 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

§

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

§

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

§

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

§

type Output = Int

The resulting type after applying the - operator.
source§

fn neg(self) -> Self

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) -> Selfwhere Self: Sized,

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

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

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

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method 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

This method 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

This method 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

This method 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

This method 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

§

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

§

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

§

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) -> Option<usize>

🔬This is a nightly-only experimental API. (step_trait)
Returns the number of successor steps required to get from start to end. 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

§

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 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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

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

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

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
§

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

§

fn vzip(self) -> V

source§

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

source§

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