Struct NumberUnderMod

Source
pub struct NumberUnderMod { /* private fields */ }
Expand description

NumberUnderMod represents a number under a certain modulus.

This struct provides methods for performing arithmetic operations (addition, subtraction, multiplication, division, and negation) under the modulus.

§Examples

let num1 = NumberUnderMod::new(5, 7); let num2 = NumberUnderMod::new(3, 7); let result = num1 + num2; assert_eq!(result.unwrap().value, 1);

Implementations§

Source§

impl NumberUnderMod

Creates a new NumberUnderMod with the given value and modulus.

The value is automatically reduced modulo the modulus.

§Examples

let num = NumberUnderMod::new(10, 7);
assert_eq!(num.value, 3);
Source

pub fn new<T: IntoU256>(value: T, modulus: T) -> Self

Trait Implementations§

Source§

impl Add for NumberUnderMod

Source§

type Output = Result<NumberUnderMod, &'static str>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl Debug for NumberUnderMod

Source§

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

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

impl Div for NumberUnderMod

Source§

type Output = Result<NumberUnderMod, &'static str>

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl Mul for NumberUnderMod

Source§

type Output = Result<NumberUnderMod, &'static str>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl Neg for NumberUnderMod

Source§

type Output = Result<NumberUnderMod, &'static str>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl PartialEq for NumberUnderMod

Source§

fn eq(&self, other: &NumberUnderMod) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Sub for NumberUnderMod

Source§

type Output = Result<NumberUnderMod, &'static str>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

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 T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V