pub trait NonZeroFactorizable: NonZero + Clone {
    type Factor: NonZero + Eq + PartialEq + Ord + PartialOrd + Hash + Clone + Debug;
    type Power: Add<Output = Self::Power> + AddAssign + Sub<Output = Self::Power> + SubAssign + One + Signed + Eq + Copy + Clone + Debug;

    // Required method
    fn factorize(&self) -> NonZeroFactorization<Self::Factor, Self::Power>;
}
Expand description

Creating a factorization of an integer or rational number.

This factorization does not necessarily consist of primes, as this can be computationally expensive.

Required Associated Types§

source

type Factor: NonZero + Eq + PartialEq + Ord + PartialOrd + Hash + Clone + Debug

Some number greater than 1, probably a prime but not necessarily.

source

type Power: Add<Output = Self::Power> + AddAssign + Sub<Output = Self::Power> + SubAssign + One + Signed + Eq + Copy + Clone + Debug

How often the factor appears in the number.

This is marked Copy, because a 64-bit power already allows for values up to 2^(2^64), which has about 5.6 * 10^18 decimal digits. Finding primes that are larger than that is too expensive.

Required Methods§

source

fn factorize(&self) -> NonZeroFactorization<Self::Factor, Self::Power>

Decompose into factors.

Note that these factors will often be, but are not guaranteed to be, primes.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl NonZeroFactorizable for i8

§

type Factor = u8

§

type Power = u32

source§

fn factorize(&self) -> NonZeroFactorization<Self::Factor, Self::Power>

source§

impl NonZeroFactorizable for i16

§

type Factor = u16

§

type Power = u32

source§

fn factorize(&self) -> NonZeroFactorization<Self::Factor, Self::Power>

source§

impl NonZeroFactorizable for i32

§

type Factor = u32

§

type Power = u32

source§

fn factorize(&self) -> NonZeroFactorization<Self::Factor, Self::Power>

source§

impl NonZeroFactorizable for i64

§

type Factor = u64

§

type Power = u32

source§

fn factorize(&self) -> NonZeroFactorization<Self::Factor, Self::Power>

source§

impl NonZeroFactorizable for u8

§

type Factor = u8

§

type Power = u32

source§

fn factorize(&self) -> NonZeroFactorization<Self::Factor, Self::Power>

source§

impl NonZeroFactorizable for u16

§

type Factor = u16

§

type Power = u32

source§

fn factorize(&self) -> NonZeroFactorization<Self::Factor, Self::Power>

source§

impl NonZeroFactorizable for u32

§

type Factor = u32

§

type Power = u32

source§

fn factorize(&self) -> NonZeroFactorization<Self::Factor, Self::Power>

source§

impl NonZeroFactorizable for u64

§

type Factor = u64

§

type Power = u32

source§

fn factorize(&self) -> NonZeroFactorization<Self::Factor, Self::Power>

source§

impl NonZeroFactorizable for NonZeroI8

§

type Factor = u8

§

type Power = u32

source§

fn factorize(&self) -> NonZeroFactorization<Self::Factor, Self::Power>

source§

impl NonZeroFactorizable for NonZeroI16

§

type Factor = u16

§

type Power = u32

source§

fn factorize(&self) -> NonZeroFactorization<Self::Factor, Self::Power>

source§

impl NonZeroFactorizable for NonZeroI32

§

type Factor = u32

§

type Power = u32

source§

fn factorize(&self) -> NonZeroFactorization<Self::Factor, Self::Power>

source§

impl NonZeroFactorizable for NonZeroI64

§

type Factor = u64

§

type Power = u32

source§

fn factorize(&self) -> NonZeroFactorization<Self::Factor, Self::Power>

source§

impl NonZeroFactorizable for NonZeroU8

§

type Factor = u8

§

type Power = u32

source§

fn factorize(&self) -> NonZeroFactorization<Self::Factor, Self::Power>

source§

impl NonZeroFactorizable for NonZeroU16

§

type Factor = u16

§

type Power = u32

source§

fn factorize(&self) -> NonZeroFactorization<Self::Factor, Self::Power>

source§

impl NonZeroFactorizable for NonZeroU32

§

type Factor = u32

§

type Power = u32

source§

fn factorize(&self) -> NonZeroFactorization<Self::Factor, Self::Power>

source§

impl NonZeroFactorizable for NonZeroU64

§

type Factor = u64

§

type Power = u32

source§

fn factorize(&self) -> NonZeroFactorization<Self::Factor, Self::Power>

Implementors§