Struct bare_metal_modulo::WrapCountNumC
source · pub struct WrapCountNumC<N: FromPrimitive, const M: usize> { /* private fields */ }
Implementations§
source§impl<N: NumType, const M: usize> WrapCountNumC<N, M>
impl<N: NumType, const M: usize> WrapCountNumC<N, M>
sourcepub fn new(a: N) -> Self
pub fn new(a: N) -> Self
Creates a new integer a (mod m), storing the number of wraparounds of a as well.
pub fn with_wraps(&self, a: N, wraps: N) -> Self
source§impl<N: NumType + Signed, const M: usize> WrapCountNumC<N, M>
impl<N: NumType + Signed, const M: usize> WrapCountNumC<N, M>
Exponentiates safely with negative exponents - if the inverse is undefined, it returns
None
, otherwise it returns Some(self.pow(rhs))
.
pub fn pow_signed(&self, rhs: N) -> Option<Self>
source§impl<N: NumType, const M: usize> WrapCountNumC<N, M>
impl<N: NumType, const M: usize> WrapCountNumC<N, M>
sourcepub fn wraps(&self) -> N
pub fn wraps(&self) -> N
Returns the total number of wraparounds counted when calculating this value.
pub fn pow_assign(&mut self, rhs: N)
source§impl<N: NumType + Signed, const M: usize> WrapCountNumC<N, M>
impl<N: NumType + Signed, const M: usize> WrapCountNumC<N, M>
sourcepub fn iter(&self) -> ModNumIterator<N, Self> ⓘ
pub fn iter(&self) -> ModNumIterator<N, Self> ⓘ
Returns an iterator starting at a (mod m) and ending at a - 1 (mod m)
sourcepub fn pow_assign_signed(&mut self, rhs: N)
pub fn pow_assign_signed(&mut self, rhs: N)
Computes and assigns to self
the value self.pow_signed(rhs)
. If the result
is undefined due to rhs
not having a defined inverse, self
will be unchanged.
Trait Implementations§
source§impl<N: NumType, const M: usize> Add<WrapCountNumC<N, M>> for WrapCountNumC<N, M>
impl<N: NumType, const M: usize> Add<WrapCountNumC<N, M>> for WrapCountNumC<N, M>
source§impl<N: NumType, const M: usize> AddAssign<N> for WrapCountNumC<N, M>
impl<N: NumType, const M: usize> AddAssign<N> for WrapCountNumC<N, M>
source§fn add_assign(&mut self, rhs: N)
fn add_assign(&mut self, rhs: N)
Performs the
+=
operation. Read moresource§impl<N: NumType, const M: usize> AddAssign<WrapCountNumC<N, M>> for WrapCountNumC<N, M>
impl<N: NumType, const M: usize> AddAssign<WrapCountNumC<N, M>> for WrapCountNumC<N, M>
source§fn add_assign(&mut self, rhs: WrapCountNumC<N, M>)
fn add_assign(&mut self, rhs: WrapCountNumC<N, M>)
Performs the
+=
operation. Read moresource§impl<N: Clone + FromPrimitive, const M: usize> Clone for WrapCountNumC<N, M>
impl<N: Clone + FromPrimitive, const M: usize> Clone for WrapCountNumC<N, M>
source§fn clone(&self) -> WrapCountNumC<N, M>
fn clone(&self) -> WrapCountNumC<N, M>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl<N: Debug + FromPrimitive, const M: usize> Debug for WrapCountNumC<N, M>
impl<N: Debug + FromPrimitive, const M: usize> Debug for WrapCountNumC<N, M>
source§impl<N: Default + FromPrimitive, const M: usize> Default for WrapCountNumC<N, M>
impl<N: Default + FromPrimitive, const M: usize> Default for WrapCountNumC<N, M>
source§fn default() -> WrapCountNumC<N, M>
fn default() -> WrapCountNumC<N, M>
Returns the “default value” for a type. Read more
source§impl<N: NumType + Signed, const M: usize> Div<WrapCountNumC<N, M>> for WrapCountNumC<N, M>
impl<N: NumType + Signed, const M: usize> Div<WrapCountNumC<N, M>> for WrapCountNumC<N, M>
source§impl<N: NumType + Signed, const M: usize> DivAssign<N> for WrapCountNumC<N, M>
impl<N: NumType + Signed, const M: usize> DivAssign<N> for WrapCountNumC<N, M>
source§fn div_assign(&mut self, rhs: N)
fn div_assign(&mut self, rhs: N)
Performs the
/=
operation. Read moresource§impl<N: NumType + Signed, const M: usize> DivAssign<WrapCountNumC<N, M>> for WrapCountNumC<N, M>
impl<N: NumType + Signed, const M: usize> DivAssign<WrapCountNumC<N, M>> for WrapCountNumC<N, M>
source§fn div_assign(&mut self, rhs: WrapCountNumC<N, M>)
fn div_assign(&mut self, rhs: WrapCountNumC<N, M>)
Performs the
/=
operation. Read moresource§impl<N: Hash + FromPrimitive, const M: usize> Hash for WrapCountNumC<N, M>
impl<N: Hash + FromPrimitive, const M: usize> Hash for WrapCountNumC<N, M>
source§impl<N: NumType, const M: usize> Mul<WrapCountNumC<N, M>> for WrapCountNumC<N, M>
impl<N: NumType, const M: usize> Mul<WrapCountNumC<N, M>> for WrapCountNumC<N, M>
source§impl<N: NumType, const M: usize> MulAssign<N> for WrapCountNumC<N, M>
impl<N: NumType, const M: usize> MulAssign<N> for WrapCountNumC<N, M>
source§fn mul_assign(&mut self, rhs: N)
fn mul_assign(&mut self, rhs: N)
Performs the
*=
operation. Read moresource§impl<N: NumType, const M: usize> MulAssign<WrapCountNumC<N, M>> for WrapCountNumC<N, M>
impl<N: NumType, const M: usize> MulAssign<WrapCountNumC<N, M>> for WrapCountNumC<N, M>
source§fn mul_assign(&mut self, rhs: WrapCountNumC<N, M>)
fn mul_assign(&mut self, rhs: WrapCountNumC<N, M>)
Performs the
*=
operation. Read moresource§impl<N: Ord + FromPrimitive, const M: usize> Ord for WrapCountNumC<N, M>
impl<N: Ord + FromPrimitive, const M: usize> Ord for WrapCountNumC<N, M>
source§fn cmp(&self, other: &WrapCountNumC<N, M>) -> Ordering
fn cmp(&self, other: &WrapCountNumC<N, M>) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl<N: NumType, const M: usize> PartialEq<N> for WrapCountNumC<N, M>
impl<N: NumType, const M: usize> PartialEq<N> for WrapCountNumC<N, M>
Returns true if other is congruent to self.a() (mod self.m())
source§impl<N: PartialEq + FromPrimitive, const M: usize> PartialEq<WrapCountNumC<N, M>> for WrapCountNumC<N, M>
impl<N: PartialEq + FromPrimitive, const M: usize> PartialEq<WrapCountNumC<N, M>> for WrapCountNumC<N, M>
source§fn eq(&self, other: &WrapCountNumC<N, M>) -> bool
fn eq(&self, other: &WrapCountNumC<N, M>) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl<N: NumType, const M: usize> PartialOrd<N> for WrapCountNumC<N, M>
impl<N: NumType, const M: usize> PartialOrd<N> for WrapCountNumC<N, M>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
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 moresource§impl<N: PartialOrd + FromPrimitive, const M: usize> PartialOrd<WrapCountNumC<N, M>> for WrapCountNumC<N, M>
impl<N: PartialOrd + FromPrimitive, const M: usize> PartialOrd<WrapCountNumC<N, M>> for WrapCountNumC<N, M>
source§fn partial_cmp(&self, other: &WrapCountNumC<N, M>) -> Option<Ordering>
fn partial_cmp(&self, other: &WrapCountNumC<N, M>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
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 moresource§impl<N: NumType, const M: usize> Pow<N> for WrapCountNumC<N, M>
impl<N: NumType, const M: usize> Pow<N> for WrapCountNumC<N, M>
source§fn pow(self, rhs: N) -> Self::Output
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 = WrapCountNumC<N, M>
type Output = WrapCountNumC<N, M>
The result after applying the operator.
source§impl<N: NumType, const M: usize> Pow<WrapCountNumC<N, M>> for WrapCountNumC<N, M>
impl<N: NumType, const M: usize> Pow<WrapCountNumC<N, M>> for WrapCountNumC<N, M>
source§impl<N: NumType + Signed, const M: usize> Sub<WrapCountNumC<N, M>> for WrapCountNumC<N, M>
impl<N: NumType + Signed, const M: usize> Sub<WrapCountNumC<N, M>> for WrapCountNumC<N, M>
§type Output = WrapCountNumC<N, M>
type Output = WrapCountNumC<N, M>
The resulting type after applying the
-
operator.source§impl<N: NumType + Signed, const M: usize> SubAssign<N> for WrapCountNumC<N, M>
impl<N: NumType + Signed, const M: usize> SubAssign<N> for WrapCountNumC<N, M>
source§fn sub_assign(&mut self, rhs: N)
fn sub_assign(&mut self, rhs: N)
Performs the
-=
operation. Read moresource§impl<N: NumType + Signed, const M: usize> SubAssign<WrapCountNumC<N, M>> for WrapCountNumC<N, M>
impl<N: NumType + Signed, const M: usize> SubAssign<WrapCountNumC<N, M>> for WrapCountNumC<N, M>
source§fn sub_assign(&mut self, rhs: WrapCountNumC<N, M>)
fn sub_assign(&mut self, rhs: WrapCountNumC<N, M>)
Performs the
-=
operation. Read more