pub struct ModuloRing(_);
Expand description

A ring of integers modulo a positive integer.

Examples

let ring = ModuloRing::new(&ubig!(100));
assert_eq!(ring.modulus(), ubig!(100));

Implementations

The ring modulus.

Example
let ring = ModuloRing::new(&ubig!(100));
assert_eq!(ring.modulus(), ubig!(100));

Create an element of the ring from another type.

Examples
let ring = ModuloRing::new(&ubig!(100));
let x = ring.from(-1234);
let y = ring.from(ubig!(3366));
assert!(x == y);

Create a new ring of integers modulo n.

For two Modulo numbers to be compatible, they must come from the same ModuloRing. Two different ModuloRings are not compatible even if they have the same modulus n.

Examples
let ring = ModuloRing::new(&ubig!(100));
assert_eq!(ring.modulus(), ubig!(100));
Panics

Panics if n is zero.

Trait Implementations

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

Equality is identity: two rings are not equal even if they have the same modulus.

This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
Formats the value using the given formatter.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.