pub trait Integer: Number {
// Required methods
fn integer_is_even(&self) -> bool;
fn integer_is_multiple_of(&self, other: &Self) -> bool;
fn integer_is_prime(&self) -> Option<bool>;
fn integer_gcd(&self, other: &Self) -> Option<Self>
where Self: Sized;
fn integer_lcm(&self, other: &Self) -> Option<Self>
where Self: Sized;
fn integer_digits(&self) -> usize;
// Provided methods
fn integer_is_odd(&self) -> bool { ... }
fn integer_is_divisor_of(&self, other: &Self) -> bool { ... }
}Expand description
Common trait for all integers.
Required Methods§
Sourcefn integer_is_even(&self) -> bool
fn integer_is_even(&self) -> bool
Returns true if this integer is even.
Sourcefn integer_is_multiple_of(&self, other: &Self) -> bool
fn integer_is_multiple_of(&self, other: &Self) -> bool
Returns true if this integer is a multiple of the other.
Sourcefn integer_is_prime(&self) -> Option<bool>
fn integer_is_prime(&self) -> Option<bool>
Sourcefn integer_gcd(&self, other: &Self) -> Option<Self>where
Self: Sized,
fn integer_gcd(&self, other: &Self) -> Option<Self>where
Self: Sized,
Calculates the Greatest Common Divisor of this integer and other.
Returns None if the operation can’t return an integer of the same kind,
e.g. for a NegativeInteger.
Sourcefn integer_lcm(&self, other: &Self) -> Option<Self>where
Self: Sized,
fn integer_lcm(&self, other: &Self) -> Option<Self>where
Self: Sized,
Calculates the Lowest Common Multiple of this integer and other.
Returns None if the operation can’t return an integer of the same kind,
e.g. for NegativeInteger.
Sourcefn integer_digits(&self) -> usize
fn integer_digits(&self) -> usize
Returns the number of digits in base 10, without the sign.
Provided Methods§
Sourcefn integer_is_odd(&self) -> bool
fn integer_is_odd(&self) -> bool
Returns true if this integer is odd.
Sourcefn integer_is_divisor_of(&self, other: &Self) -> bool
fn integer_is_divisor_of(&self, other: &Self) -> bool
Returns true if this integer is a divisor of the other.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl Integer for i8
impl Integer for i8
fn integer_is_even(&self) -> bool
fn integer_is_multiple_of(&self, other: &Self) -> bool
fn integer_is_prime(&self) -> Option<bool>
fn integer_gcd(&self, other: &Self) -> Option<Self>
fn integer_lcm(&self, other: &Self) -> Option<Self>
fn integer_digits(&self) -> usize
Source§impl Integer for i16
impl Integer for i16
fn integer_is_even(&self) -> bool
fn integer_is_multiple_of(&self, other: &Self) -> bool
fn integer_is_prime(&self) -> Option<bool>
fn integer_gcd(&self, other: &Self) -> Option<Self>
fn integer_lcm(&self, other: &Self) -> Option<Self>
fn integer_digits(&self) -> usize
Source§impl Integer for i32
impl Integer for i32
fn integer_is_even(&self) -> bool
fn integer_is_multiple_of(&self, other: &Self) -> bool
fn integer_is_prime(&self) -> Option<bool>
fn integer_gcd(&self, other: &Self) -> Option<Self>
fn integer_lcm(&self, other: &Self) -> Option<Self>
fn integer_digits(&self) -> usize
Source§impl Integer for i64
impl Integer for i64
fn integer_is_even(&self) -> bool
fn integer_is_multiple_of(&self, other: &Self) -> bool
fn integer_is_prime(&self) -> Option<bool>
fn integer_gcd(&self, other: &Self) -> Option<Self>
fn integer_lcm(&self, other: &Self) -> Option<Self>
fn integer_digits(&self) -> usize
Source§impl Integer for i128
impl Integer for i128
fn integer_is_even(&self) -> bool
fn integer_is_multiple_of(&self, other: &Self) -> bool
fn integer_is_prime(&self) -> Option<bool>
fn integer_gcd(&self, other: &Self) -> Option<Self>
fn integer_lcm(&self, other: &Self) -> Option<Self>
fn integer_digits(&self) -> usize
Source§impl Integer for isize
impl Integer for isize
fn integer_is_even(&self) -> bool
fn integer_is_multiple_of(&self, other: &Self) -> bool
fn integer_is_prime(&self) -> Option<bool>
fn integer_gcd(&self, other: &Self) -> Option<Self>
fn integer_lcm(&self, other: &Self) -> Option<Self>
fn integer_digits(&self) -> usize
Source§impl Integer for u8
impl Integer for u8
fn integer_is_even(&self) -> bool
fn integer_is_multiple_of(&self, other: &Self) -> bool
fn integer_is_prime(&self) -> Option<bool>
fn integer_gcd(&self, other: &Self) -> Option<Self>
fn integer_lcm(&self, other: &Self) -> Option<Self>
fn integer_digits(&self) -> usize
Source§impl Integer for u16
impl Integer for u16
fn integer_is_even(&self) -> bool
fn integer_is_multiple_of(&self, other: &Self) -> bool
fn integer_is_prime(&self) -> Option<bool>
fn integer_gcd(&self, other: &Self) -> Option<Self>
fn integer_lcm(&self, other: &Self) -> Option<Self>
fn integer_digits(&self) -> usize
Source§impl Integer for u32
impl Integer for u32
fn integer_is_even(&self) -> bool
fn integer_is_multiple_of(&self, other: &Self) -> bool
fn integer_is_prime(&self) -> Option<bool>
fn integer_gcd(&self, other: &Self) -> Option<Self>
fn integer_lcm(&self, other: &Self) -> Option<Self>
fn integer_digits(&self) -> usize
Source§impl Integer for u64
impl Integer for u64
fn integer_is_even(&self) -> bool
fn integer_is_multiple_of(&self, other: &Self) -> bool
fn integer_is_prime(&self) -> Option<bool>
fn integer_gcd(&self, other: &Self) -> Option<Self>
fn integer_lcm(&self, other: &Self) -> Option<Self>
fn integer_digits(&self) -> usize
Source§impl Integer for u128
impl Integer for u128
fn integer_is_even(&self) -> bool
fn integer_is_multiple_of(&self, other: &Self) -> bool
fn integer_is_prime(&self) -> Option<bool>
fn integer_gcd(&self, other: &Self) -> Option<Self>
fn integer_lcm(&self, other: &Self) -> Option<Self>
fn integer_digits(&self) -> usize
Source§impl Integer for usize
impl Integer for usize
fn integer_is_even(&self) -> bool
fn integer_is_multiple_of(&self, other: &Self) -> bool
fn integer_is_prime(&self) -> Option<bool>
fn integer_gcd(&self, other: &Self) -> Option<Self>
fn integer_lcm(&self, other: &Self) -> Option<Self>
fn integer_digits(&self) -> usize
Source§impl Integer for NonZeroI8
impl Integer for NonZeroI8
fn integer_is_even(&self) -> bool
fn integer_is_multiple_of(&self, other: &Self) -> bool
fn integer_is_prime(&self) -> Option<bool>
fn integer_gcd(&self, other: &Self) -> Option<Self>
fn integer_lcm(&self, other: &Self) -> Option<Self>
fn integer_digits(&self) -> usize
Source§impl Integer for NonZeroI16
impl Integer for NonZeroI16
fn integer_is_even(&self) -> bool
fn integer_is_multiple_of(&self, other: &Self) -> bool
fn integer_is_prime(&self) -> Option<bool>
fn integer_gcd(&self, other: &Self) -> Option<Self>
fn integer_lcm(&self, other: &Self) -> Option<Self>
fn integer_digits(&self) -> usize
Source§impl Integer for NonZeroI32
impl Integer for NonZeroI32
fn integer_is_even(&self) -> bool
fn integer_is_multiple_of(&self, other: &Self) -> bool
fn integer_is_prime(&self) -> Option<bool>
fn integer_gcd(&self, other: &Self) -> Option<Self>
fn integer_lcm(&self, other: &Self) -> Option<Self>
fn integer_digits(&self) -> usize
Source§impl Integer for NonZeroI64
impl Integer for NonZeroI64
fn integer_is_even(&self) -> bool
fn integer_is_multiple_of(&self, other: &Self) -> bool
fn integer_is_prime(&self) -> Option<bool>
fn integer_gcd(&self, other: &Self) -> Option<Self>
fn integer_lcm(&self, other: &Self) -> Option<Self>
fn integer_digits(&self) -> usize
Source§impl Integer for NonZeroI128
impl Integer for NonZeroI128
fn integer_is_even(&self) -> bool
fn integer_is_multiple_of(&self, other: &Self) -> bool
fn integer_is_prime(&self) -> Option<bool>
fn integer_gcd(&self, other: &Self) -> Option<Self>
fn integer_lcm(&self, other: &Self) -> Option<Self>
fn integer_digits(&self) -> usize
Source§impl Integer for NonZeroIsize
impl Integer for NonZeroIsize
fn integer_is_even(&self) -> bool
fn integer_is_multiple_of(&self, other: &Self) -> bool
fn integer_is_prime(&self) -> Option<bool>
fn integer_gcd(&self, other: &Self) -> Option<Self>
fn integer_lcm(&self, other: &Self) -> Option<Self>
fn integer_digits(&self) -> usize
Source§impl Integer for NonZeroU8
impl Integer for NonZeroU8
fn integer_is_even(&self) -> bool
fn integer_is_multiple_of(&self, other: &Self) -> bool
fn integer_is_prime(&self) -> Option<bool>
fn integer_gcd(&self, other: &Self) -> Option<Self>
fn integer_lcm(&self, other: &Self) -> Option<Self>
fn integer_digits(&self) -> usize
Source§impl Integer for NonZeroU16
impl Integer for NonZeroU16
fn integer_is_even(&self) -> bool
fn integer_is_multiple_of(&self, other: &Self) -> bool
fn integer_is_prime(&self) -> Option<bool>
fn integer_gcd(&self, other: &Self) -> Option<Self>
fn integer_lcm(&self, other: &Self) -> Option<Self>
fn integer_digits(&self) -> usize
Source§impl Integer for NonZeroU32
impl Integer for NonZeroU32
fn integer_is_even(&self) -> bool
fn integer_is_multiple_of(&self, other: &Self) -> bool
fn integer_is_prime(&self) -> Option<bool>
fn integer_gcd(&self, other: &Self) -> Option<Self>
fn integer_lcm(&self, other: &Self) -> Option<Self>
fn integer_digits(&self) -> usize
Source§impl Integer for NonZeroU64
impl Integer for NonZeroU64
fn integer_is_even(&self) -> bool
fn integer_is_multiple_of(&self, other: &Self) -> bool
fn integer_is_prime(&self) -> Option<bool>
fn integer_gcd(&self, other: &Self) -> Option<Self>
fn integer_lcm(&self, other: &Self) -> Option<Self>
fn integer_digits(&self) -> usize
Source§impl Integer for NonZeroU128
impl Integer for NonZeroU128
fn integer_is_even(&self) -> bool
fn integer_is_multiple_of(&self, other: &Self) -> bool
fn integer_is_prime(&self) -> Option<bool>
fn integer_gcd(&self, other: &Self) -> Option<Self>
fn integer_lcm(&self, other: &Self) -> Option<Self>
fn integer_digits(&self) -> usize
Source§impl Integer for NonZeroUsize
impl Integer for NonZeroUsize
fn integer_is_even(&self) -> bool
fn integer_is_multiple_of(&self, other: &Self) -> bool
fn integer_is_prime(&self) -> Option<bool>
fn integer_gcd(&self, other: &Self) -> Option<Self>
fn integer_lcm(&self, other: &Self) -> Option<Self>
fn integer_digits(&self) -> usize
Implementors§
impl Integer for Integer8
impl Integer for Integer16
impl Integer for Integer128
impl Integer for IntegerBig
Available on crate feature
dashu-int only.