Struct ibig::modular::ModuloRing
source · [−]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
sourceimpl ModuloRing
impl ModuloRing
sourcepub fn modulus(&self) -> UBig
pub fn modulus(&self) -> UBig
The ring modulus.
Example
let ring = ModuloRing::new(&ubig!(100));
assert_eq!(ring.modulus(), ubig!(100));
sourcepub fn from<T: IntoModulo>(&self, x: T) -> Modulo<'_>
pub fn from<T: IntoModulo>(&self, x: T) -> Modulo<'_>
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);
sourceimpl ModuloRing
impl ModuloRing
sourcepub fn new(n: &UBig) -> ModuloRing
pub fn new(n: &UBig) -> ModuloRing
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
sourceimpl Binary for ModuloRing
impl Binary for ModuloRing
sourceimpl Debug for ModuloRing
impl Debug for ModuloRing
sourceimpl Display for ModuloRing
impl Display for ModuloRing
sourceimpl LowerHex for ModuloRing
impl LowerHex for ModuloRing
sourceimpl Octal for ModuloRing
impl Octal for ModuloRing
sourceimpl PartialEq<ModuloRing> for ModuloRing
impl PartialEq<ModuloRing> for ModuloRing
Equality is identity: two rings are not equal even if they have the same modulus.
sourceimpl UpperHex for ModuloRing
impl UpperHex for ModuloRing
impl Eq for ModuloRing
Auto Trait Implementations
impl RefUnwindSafe for ModuloRing
impl Send for ModuloRing
impl Sync for ModuloRing
impl Unpin for ModuloRing
impl UnwindSafe for ModuloRing
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more