Skip to main content

DivExact

Trait DivExact 

Source
pub trait DivExact<Rhs, Precompute>: Sized {
    type Output;

    // Required method
    fn div_exact(self, d: Rhs, pre: &Precompute) -> Option<Self::Output>;
}
Expand description

Exact division, re-exported from num-modular.

DivExact<Rhs, Precompute>::div_exact(self, rhs, pre) returns Some(self / rhs) when rhs divides self exactly and None otherwise. dashu’s implementations use the empty precomputation Precompute = () (pass &() at the call site). For arbitrary-precision types an exact division avoids the general division’s normalization and remainder computation when the divisor is small (e.g. dashu-int uses Hensel 2-adic division). Utility function for exact division, with precomputed helper values

§Available Pre-computation types:

  • (): No pre-computation, the implementation relies on native integer division
  • PreModInv: With Pre-computed modular inverse

Required Associated Types§

Required Methods§

Source

fn div_exact(self, d: Rhs, pre: &Precompute) -> Option<Self::Output>

Check if d divides self with the help of the precomputation. If d divides self, then the quotient is returned.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl DivExact<u8, ()> for u8

Source§

type Output = u8

Source§

fn div_exact(self, d: u8, _: &()) -> Option<<u8 as DivExact<u8, ()>>::Output>

Source§

impl DivExact<u8, PreModInv<u8>> for u8

Source§

type Output = u8

Source§

fn div_exact(self, d: u8, pre: &PreModInv<u8>) -> Option<u8>

Source§

impl DivExact<u8, PreModInv<u8>> for u16

Source§

impl DivExact<u8, PreMulInv1by1<u8>> for u8

Source§

impl DivExact<u16, ()> for u16

Source§

type Output = u16

Source§

fn div_exact(self, d: u16, _: &()) -> Option<<u16 as DivExact<u16, ()>>::Output>

Source§

impl DivExact<u16, PreModInv<u16>> for u16

Source§

impl DivExact<u16, PreModInv<u16>> for u32

Source§

impl DivExact<u16, PreMulInv1by1<u16>> for u16

Source§

impl DivExact<u32, ()> for u32

Source§

type Output = u32

Source§

fn div_exact(self, d: u32, _: &()) -> Option<<u32 as DivExact<u32, ()>>::Output>

Source§

impl DivExact<u32, PreModInv<u32>> for u32

Source§

impl DivExact<u32, PreModInv<u32>> for u64

Source§

impl DivExact<u32, PreMulInv1by1<u32>> for u32

Source§

impl DivExact<u64, ()> for u64

Source§

type Output = u64

Source§

fn div_exact(self, d: u64, _: &()) -> Option<<u64 as DivExact<u64, ()>>::Output>

Source§

impl DivExact<u64, PreModInv<u64>> for u64

Source§

impl DivExact<u64, PreModInv<u64>> for u128

Source§

impl DivExact<u64, PreMulInv1by1<u64>> for u64

Source§

impl DivExact<u128, ()> for u128

Source§

type Output = u128

Source§

fn div_exact( self, d: u128, _: &(), ) -> Option<<u128 as DivExact<u128, ()>>::Output>

Source§

impl DivExact<usize, PreModInv<usize>> for u128

Source§

impl DivExact<usize, PreModInv<usize>> for usize

Source§

impl DivExact<usize, PreMulInv1by1<usize>> for usize

Implementors§