pub struct ModNumC<N: FromPrimitive, const M: usize> { /* private fields */ }
Expand description

Represents an integer a (mod M)

Implementations§

source§

impl<N: NumType, const M: usize> ModNumC<N, M>

source

pub fn new(num: N) -> Self

source

pub fn iter(&self) -> ModNumIterator<N, Self>

Returns an iterator starting at a (mod m) and ending at a - 1 (mod m)

source§

impl<N: NumType + Signed, const M: usize> ModNumC<N, M>

Exponentiates safely with negative exponents - if the inverse is undefined, it returns None, otherwise it returns Some(self.pow(rhs)).

source

pub fn pow_signed(&self, rhs: N) -> Option<Self>

Trait Implementations§

source§

impl<N: NumType, const M: usize> Add<ModNumC<N, M>> for ModNumC<N, M>

§

type Output = ModNumC<N, M>

The resulting type after applying the + operator.
source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
source§

impl<N: NumType, const M: usize> Add<N> for ModNumC<N, M>

§

type Output = ModNumC<N, M>

The resulting type after applying the + operator.
source§

fn add(self, rhs: N) -> Self::Output

Performs the + operation. Read more
source§

impl<N: NumType, const M: usize> AddAssign<ModNumC<N, M>> for ModNumC<N, M>

source§

fn add_assign(&mut self, rhs: ModNumC<N, M>)

Performs the += operation. Read more
source§

impl<N: NumType, const M: usize> AddAssign<N> for ModNumC<N, M>

source§

fn add_assign(&mut self, rhs: N)

Performs the += operation. Read more
source§

impl<N: Clone + FromPrimitive, const M: usize> Clone for ModNumC<N, M>

source§

fn clone(&self) -> ModNumC<N, M>

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<N: Debug + FromPrimitive, const M: usize> Debug for ModNumC<N, M>

source§

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

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

impl<N: Default + FromPrimitive, const M: usize> Default for ModNumC<N, M>

source§

fn default() -> ModNumC<N, M>

Returns the “default value” for a type. Read more
source§

impl<N: NumType, const M: usize> Display for ModNumC<N, M>

source§

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

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

impl<N: NumType + Signed, const M: usize> Div<ModNumC<N, M>> for ModNumC<N, M>

§

type Output = Option<ModNumC<N, M>>

The resulting type after applying the / operator.
source§

fn div(self, rhs: Self) -> Self::Output

Performs the / operation. Read more
source§

impl<N: NumType + Signed, const M: usize> Div<N> for ModNumC<N, M>

§

type Output = Option<ModNumC<N, M>>

The resulting type after applying the / operator.
source§

fn div(self, rhs: N) -> Self::Output

Performs the / operation. Read more
source§

impl<N: NumType + Signed, const M: usize> DivAssign<ModNumC<N, M>> for ModNumC<N, M>

source§

fn div_assign(&mut self, rhs: ModNumC<N, M>)

Performs the /= operation. Read more
source§

impl<N: NumType + Signed, const M: usize> DivAssign<N> for ModNumC<N, M>

source§

fn div_assign(&mut self, rhs: N)

Performs the /= operation. Read more
source§

impl<N: Hash + FromPrimitive, const M: usize> Hash for ModNumC<N, M>

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<N: NumType, const M: usize> MNum for ModNumC<N, M>

§

type Num = N

source§

fn a(&self) -> Self::Num

source§

fn m(&self) -> Self::Num

source§

fn with(&self, new_a: Self::Num) -> Self

source§

fn replace(&mut self, new_a: Self::Num)

source§

impl<N: NumType, const M: usize> Mul<ModNumC<N, M>> for ModNumC<N, M>

§

type Output = ModNumC<N, M>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Self) -> Self::Output

Performs the * operation. Read more
source§

impl<N: NumType, const M: usize> Mul<N> for ModNumC<N, M>

§

type Output = ModNumC<N, M>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: N) -> Self::Output

Performs the * operation. Read more
source§

impl<N: NumType, const M: usize> MulAssign<ModNumC<N, M>> for ModNumC<N, M>

source§

fn mul_assign(&mut self, rhs: ModNumC<N, M>)

Performs the *= operation. Read more
source§

impl<N: NumType, const M: usize> MulAssign<N> for ModNumC<N, M>

source§

fn mul_assign(&mut self, rhs: N)

Performs the *= operation. Read more
source§

impl<N: NumType, const M: usize> Neg for ModNumC<N, M>

§

type Output = ModNumC<N, M>

The resulting type after applying the - operator.
source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
source§

impl<N: Ord + FromPrimitive, const M: usize> Ord for ModNumC<N, M>

source§

fn cmp(&self, other: &ModNumC<N, M>) -> 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<N: PartialEq + FromPrimitive, const M: usize> PartialEq<ModNumC<N, M>> for ModNumC<N, M>

source§

fn eq(&self, other: &ModNumC<N, M>) -> 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<N: NumType, const M: usize> PartialEq<N> for ModNumC<N, M>

Returns true if other is congruent to self.a() (mod self.m())

source§

fn eq(&self, other: &N) -> 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<N: PartialOrd + FromPrimitive, const M: usize> PartialOrd<ModNumC<N, M>> for ModNumC<N, M>

source§

fn partial_cmp(&self, other: &ModNumC<N, M>) -> 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<N: NumType, const M: usize> PartialOrd<N> for ModNumC<N, M>

source§

fn partial_cmp(&self, other: &N) -> 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<N: NumType, const M: usize> Pow<ModNumC<N, M>> for ModNumC<N, M>

§

type Output = ModNumC<N, M>

The result after applying the operator.
source§

fn pow(self, rhs: Self) -> Self::Output

Returns self to the power rhs. Read more
source§

impl<N: NumType, const M: usize> Pow<N> for ModNumC<N, M>

source§

fn pow(self, rhs: N) -> Self::Output

Returns a^rhs (mod m), for rhs >= 0. Implements efficient modular exponentiation by repeated squaring.

Panics if rhs < 0. If negative exponents are possible, use .pow_signed()

§

type Output = ModNumC<N, M>

The result after applying the operator.
source§

impl<N: NumType, const M: usize> SaturatingAdd for ModNumC<N, M>

source§

fn saturating_add(&self, v: &Self) -> Self

Saturating addition. Computes self + other, saturating at the relevant high or low boundary of the type.
source§

impl<N: NumType, const M: usize> SaturatingSub for ModNumC<N, M>

source§

fn saturating_sub(&self, v: &Self) -> Self

Saturating subtraction. Computes self - other, saturating at the relevant high or low boundary of the type.
source§

impl<N: NumType, const M: usize> Sub<ModNumC<N, M>> for ModNumC<N, M>

§

type Output = ModNumC<N, M>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
source§

impl<N: NumType, const M: usize> Sub<N> for ModNumC<N, M>

§

type Output = ModNumC<N, M>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: N) -> Self::Output

Performs the - operation. Read more
source§

impl<N: NumType, const M: usize> SubAssign<ModNumC<N, M>> for ModNumC<N, M>

source§

fn sub_assign(&mut self, rhs: ModNumC<N, M>)

Performs the -= operation. Read more
source§

impl<N: NumType, const M: usize> SubAssign<N> for ModNumC<N, M>

source§

fn sub_assign(&mut self, rhs: N)

Performs the -= operation. Read more
source§

impl<N: Copy + FromPrimitive, const M: usize> Copy for ModNumC<N, M>

source§

impl<N: Eq + FromPrimitive, const M: usize> Eq for ModNumC<N, M>

source§

impl<N: FromPrimitive, const M: usize> StructuralEq for ModNumC<N, M>

source§

impl<N: FromPrimitive, const M: usize> StructuralPartialEq for ModNumC<N, M>

Auto Trait Implementations§

§

impl<N, const M: usize> RefUnwindSafe for ModNumC<N, M>where N: RefUnwindSafe,

§

impl<N, const M: usize> Send for ModNumC<N, M>where N: Send,

§

impl<N, const M: usize> Sync for ModNumC<N, M>where N: Sync,

§

impl<N, const M: usize> Unpin for ModNumC<N, M>where N: Unpin,

§

impl<N, const M: usize> UnwindSafe for ModNumC<N, M>where N: UnwindSafe,

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