[][src]Enum modtype::cartridges::ManuallyAdjust

pub enum ManuallyAdjust<T: UnsignedPrimitive> {
    Infallible(InfalliblePhantomData<fn() -> T>),
}

A Cartridge which does not automatically adjust the inner value.

use num::CheckedAdd as _;

#[modtype::use_modtype]
type Z = modtype::ModType<modtype::cartridges::ManuallyAdjust<u64>, 1_000_000_007u64>;

let mut x = Z(1_000_000_006);

x += Z(u64::max_value() - 1_000_000_006);
assert_eq!(*x.get_mut_unchecked(), u64::max_value());

x.adjust();
assert_eq!(*x.get_mut_unchecked(), u64::max_value() % 1_000_000_007);

Variants

Infallible(InfalliblePhantomData<fn() -> T>)

Trait Implementations

impl<T: UnsignedPrimitive> Cartridge for ManuallyAdjust<T>[src]

type Target = T

type AssumePrimeModulus = False

type AssumeAlwaysAdjusted = False

type Equality = False

type Order = False

type Deref = False

type PartialAddition = True

type PartialSubtraction = True

type PartialMultiplication = True

type PartialDivision = False

type FlexibleRhs = False

fn new<T: PrimInt>(raw: T, modulus: T) -> T[src]

Implementation for [From]<Self::Target> and modtype{, ::thread_local}::ModType::new. Read more

fn adjust<T: PrimInt>(raw: &mut T, modulus: T)[src]

Make *raw *raw % modulus. Read more

fn adjusted<T: PrimInt>(raw: T, modulus: T) -> T[src]

Make raw raw % modulus. Read more

fn from_u8(value: u8, modulus: Self::Target) -> Self::Target[src]

Implementation for [From]::<[u8]> and [FromPrimitive]::[from_u8]. Read more

fn from_u16(value: u16, modulus: Self::Target) -> Self::Target[src]

Implementation for [From]::<[u16]> and [FromPrimitive]::[from_u16]. Read more

fn from_u32(value: u32, modulus: Self::Target) -> Self::Target[src]

Implementation for [From]::<[u32]> and [FromPrimitive]::[from_u32]. Read more

fn from_u64(value: u64, modulus: Self::Target) -> Self::Target[src]

Implementation for [From]::<[u64]> and [FromPrimitive]::[from_u64]. Read more

fn from_u128(value: u128, modulus: Self::Target) -> Self::Target[src]

Implementation for [From]::<[u128]> and [FromPrimitive]::[from_u128]. Read more

fn from_usize(value: usize, modulus: Self::Target) -> Self::Target[src]

Implementation for [From]::<[usize]> and [FromPrimitive]::[from_usize]. Read more

fn from_i8(value: i8, modulus: Self::Target) -> Self::Target where
    Self::PartialSubtraction: IsTrue
[src]

Implementation for [From]::<[i8]> and [FromPrimitive]::[from_i8]. Read more

fn from_i16(value: i16, modulus: Self::Target) -> Self::Target where
    Self::PartialSubtraction: IsTrue
[src]

Implementation for [From]::<[i16]> and [FromPrimitive]::[from_i16]. Read more

fn from_i32(value: i32, modulus: Self::Target) -> Self::Target where
    Self::PartialSubtraction: IsTrue
[src]

Implementation for [From]::<[i32]> and [FromPrimitive]::[from_i32]. Read more

fn from_i64(value: i64, modulus: Self::Target) -> Self::Target where
    Self::PartialSubtraction: IsTrue
[src]

Implementation for [From]::<[i64]> and [FromPrimitive]::[from_i64]. Read more

fn from_i128(value: i128, modulus: Self::Target) -> Self::Target where
    Self::PartialSubtraction: IsTrue
[src]

Implementation for [From]::<[i128]> and [FromPrimitive]::[from_i128]. Read more

fn from_isize(value: isize, modulus: Self::Target) -> Self::Target where
    Self::PartialSubtraction: IsTrue
[src]

Implementation for [From]::<[isize]> and [FromPrimitive]::[from_isize]. Read more

fn from_float_prim<F: FloatPrimitive>(
    value: F,
    modulus: Self::Target
) -> Self::Target where
    Self::AssumePrimeModulus: IsTrue,
    Self::PartialSubtraction: IsTrue,
    Self::PartialMultiplication: IsTrue,
    Self::PartialDivision: IsTrue
[src]

Implementation for [From]::<[f32], [f64]> and [FromPrimitive]::{[from_f32], [from_f64]}. Read more

fn from_biguint(value: BigUint, modulus: Self::Target) -> Self::Target[src]

Implementation for [From]<[BigUint]>. Read more

fn from_bigint(value: BigInt, modulus: Self::Target) -> Self::Target where
    Self::PartialSubtraction: IsTrue
[src]

Implementation for [From]<[BigInt]>. Read more

fn from_biguint_ratio(
    value: Ratio<BigUint>,
    modulus: Self::Target
) -> Self::Target where
    Self::AssumePrimeModulus: IsTrue,
    Self::PartialDivision: IsTrue
[src]

Implementation for [From]<[Ratio]<[BigUint]>>. Read more

fn from_bigint_ratio(
    value: Ratio<BigInt>,
    modulus: Self::Target
) -> Self::Target where
    Self::AssumePrimeModulus: IsTrue,
    Self::PartialSubtraction: IsTrue,
    Self::PartialDivision: IsTrue
[src]

Implementation for [From]<[Ratio]<[BigInt]>>. Read more

fn eq(lhs: Self::Target, rhs: Self::Target, modulus: Self::Target) -> bool where
    Self::Equality: IsTrue
[src]

Implementation for [PartialEq]::[eq]. Read more

fn cmp(lhs: Self::Target, rhs: Self::Target, modulus: Self::Target) -> Ordering where
    Self::Equality: IsTrue,
    Self::Order: IsTrue
[src]

Implementation for [PartialOrd]::[partial_cmp] and [Ord]::[cmp]. Read more

fn fmt_display(
    value: Self::Target,
    modulus: Self::Target,
    fmt: &mut Formatter
) -> Result
[src]

Implementation for [Display]. Read more

fn from_str(
    str: &str,
    modulus: Self::Target
) -> Result<Self::Target, ParseIntError>
[src]

Implementation for [FromStr]. Read more

fn neg(value: Self::Target, modulus: Self::Target) -> Self::Target where
    Self::PartialSubtraction: IsTrue
[src]

Implementation for [Neg]. Read more

fn div(
    lhs: Self::Target,
    rhs: Self::Target,
    modulus: Self::Target
) -> Self::Target where
    Self::PartialDivision: IsTrue
[src]

Implementation for [Div]. Read more

fn rem(
    _lhs: Self::Target,
    rhs: Self::Target,
    modulus: Self::Target
) -> Self::Target where
    Self::PartialDivision: IsTrue
[src]

Implementation for [Rem]. Read more

fn inv(value: Self::Target, modulus: Self::Target) -> Self::Target where
    Self::PartialDivision: IsTrue
[src]

Implementation for [Inv]. Read more

fn from_str_radix(
    str: &str,
    radix: u32,
    modulus: Self::Target
) -> Result<Self::Target, ParseIntError> where
    Self::AssumePrimeModulus: IsTrue,
    Self::Equality: IsTrue,
    Self::Order: IsTrue,
    Self::PartialAddition: IsTrue,
    Self::PartialSubtraction: IsTrue,
    Self::PartialMultiplication: IsTrue,
    Self::PartialDivision: IsTrue
[src]

Implementation for [Num]. Read more

fn zero(_modulus: Self::Target) -> Self::Target where
    Self::PartialAddition: IsTrue
[src]

Implementation for [Zero]::[zero]. Read more

fn is_zero(value: Self::Target, modulus: Self::Target) -> bool where
    Self::PartialAddition: IsTrue
[src]

Implementation for [Zero]::[is_zero]. Read more

fn one(_modulus: Self::Target) -> Self::Target where
    Self::PartialMultiplication: IsTrue
[src]

Implementation for [One]::[one]. Read more

fn is_one(value: Self::Target, modulus: Self::Target) -> bool where
    Self::Equality: IsTrue,
    Self::PartialMultiplication: IsTrue
[src]

Implementation for [One]::[is_one]. Read more

fn checked_neg(
    value: Self::Target,
    modulus: Self::Target
) -> Option<Self::Target> where
    Self::PartialSubtraction: IsTrue
[src]

Implementation for [CheckedNeg]. Read more

fn checked_div(
    lhs: Self::Target,
    rhs: Self::Target,
    modulus: Self::Target
) -> Option<Self::Target> where
    Self::PartialDivision: IsTrue
[src]

Implementation for [CheckedDiv]. Read more

fn checked_rem(
    _lhs: Self::Target,
    rhs: Self::Target,
    modulus: Self::Target
) -> Option<Self::Target> where
    Self::PartialDivision: IsTrue
[src]

Implementation for [CheckedRem]. Read more

fn pow_unsigned<E: UnsignedPrimitive>(
    base: Self::Target,
    exp: E,
    modulus: Self::Target
) -> Self::Target where
    Self::PartialMultiplication: IsTrue
[src]

Implementation for [Pow]<{[u8], [u16], [u32], [u64], [u128], [usize]}>. Read more

fn pow_signed<E: SignedPrimitive>(
    base: Self::Target,
    exp: E,
    modulus: Self::Target
) -> Self::Target where
    Self::AssumePrimeModulus: IsTrue,
    Self::PartialMultiplication: IsTrue,
    Self::PartialDivision: IsTrue
[src]

Implementation for [Pow]<{[i8], [i16], [i32], [i64], [i128], [isize]}>. Read more

Auto Trait Implementations

impl<T> Unpin for ManuallyAdjust<T>

impl<T> Sync for ManuallyAdjust<T>

impl<T> Send for ManuallyAdjust<T>

impl<T> RefUnwindSafe for ManuallyAdjust<T>

impl<T> UnwindSafe for ManuallyAdjust<T>

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]