pub struct Modular { /* private fields */ }Expand description
A normalized modular residue paired with its positive modulus.
Implementations§
Source§impl Modular
impl Modular
Sourcepub fn new(value: i64, modulus: i64) -> Option<Self>
pub fn new(value: i64, modulus: i64) -> Option<Self>
Creates a normalized modular value.
Returns None when modulus <= 0.
Sourcepub fn add(self, other: Self) -> Option<Self>
pub fn add(self, other: Self) -> Option<Self>
Adds two modular values with the same modulus.
Returns None when the moduli differ.
Sourcepub fn sub(self, other: Self) -> Option<Self>
pub fn sub(self, other: Self) -> Option<Self>
Subtracts two modular values with the same modulus.
Returns None when the moduli differ.
Sourcepub fn mul(self, other: Self) -> Option<Self>
pub fn mul(self, other: Self) -> Option<Self>
Multiplies two modular values with the same modulus.
Returns None when the moduli differ.
Trait Implementations§
impl Copy for Modular
impl Eq for Modular
impl StructuralPartialEq for Modular
Auto Trait Implementations§
impl Freeze for Modular
impl RefUnwindSafe for Modular
impl Send for Modular
impl Sync for Modular
impl Unpin for Modular
impl UnsafeUnpin for Modular
impl UnwindSafe for Modular
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more