Skip to main content

Primality

Trait Primality 

Source
pub trait Primality:
    Clone
    + Copy
    + AddAssign
    + SubAssign
    + PartialOrd {
    const ONE: Self;
    const FIRST_PRIME: Self;
    const LAST_PRIME: Self;

    // Required methods
    fn is_prime(&self) -> bool;
    fn strong_case(&self) -> bool;
}
Expand description

Trait for primality over all primitive types

Required Associated Constants§

Source

const ONE: Self

Unit of the Set

Source

const FIRST_PRIME: Self

Minimum prime in the set

Source

const LAST_PRIME: Self

Maximum prime in the set

Required Methods§

Source

fn is_prime(&self) -> bool

Returns true if prime

Source

fn strong_case(&self) -> bool

Minimal computation for primality proving

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 Primality for f32

Source§

const ONE: Self = 1f32

Source§

const FIRST_PRIME: Self = -16777213f32

Source§

const LAST_PRIME: Self = 16777213f32

Source§

fn is_prime(&self) -> bool

Source§

fn strong_case(&self) -> bool

Source§

impl Primality for f64

Source§

const ONE: Self = 1f64

Source§

const FIRST_PRIME: Self = -9007199254740881f64

Source§

const LAST_PRIME: Self = 9007199254740881f64

Source§

fn is_prime(&self) -> bool

Source§

fn strong_case(&self) -> bool

Source§

impl Primality for i8

Source§

const ONE: Self = 0x1

Source§

const FIRST_PRIME: Self = -0x7F

Source§

const LAST_PRIME: Self = 0x7F

Source§

fn is_prime(&self) -> bool

Source§

fn strong_case(&self) -> bool

Source§

impl Primality for i16

Source§

const ONE: Self = 0x1

Source§

const FIRST_PRIME: Self = -0x7FED

Source§

const LAST_PRIME: Self = 0x7FED

Source§

fn is_prime(&self) -> bool

Source§

fn strong_case(&self) -> bool

Source§

impl Primality for i32

Source§

const ONE: Self = 0x1

Source§

const FIRST_PRIME: Self = -0x7FFFFFFF

Source§

const LAST_PRIME: Self = 0x7FFFFFFF

Source§

fn is_prime(&self) -> bool

Source§

fn strong_case(&self) -> bool

Source§

impl Primality for i64

Source§

const ONE: Self = 0x1

Source§

const FIRST_PRIME: Self = -0x7FFFFFFFFFFFFFE7

Source§

const LAST_PRIME: Self = 0x7FFFFFFFFFFFFFE7

Source§

fn is_prime(&self) -> bool

Source§

fn strong_case(&self) -> bool

Source§

impl Primality for i128

Source§

const ONE: Self = 0x1

Source§

const FIRST_PRIME: Self = -0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF

Source§

const LAST_PRIME: Self = 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF

Source§

fn is_prime(&self) -> bool

Source§

fn strong_case(&self) -> bool

Source§

impl Primality for isize

Source§

const ONE: Self = 0x1

Source§

const FIRST_PRIME: Self = -0x7FFFFFFFFFFFFFE7

Source§

const LAST_PRIME: Self = 0x7FFFFFFFFFFFFFE7

Source§

fn is_prime(&self) -> bool

Source§

fn strong_case(&self) -> bool

Source§

impl Primality for u8

Source§

const ONE: Self = 0x1

Source§

const FIRST_PRIME: Self = 0x2

Source§

const LAST_PRIME: Self = 0xFB

Source§

fn is_prime(&self) -> bool

Source§

fn strong_case(&self) -> bool

Source§

impl Primality for u16

Source§

const ONE: Self = 0x1

Source§

const FIRST_PRIME: Self = 0x2

Source§

const LAST_PRIME: Self = 0xFFF1

Source§

fn is_prime(&self) -> bool

Source§

fn strong_case(&self) -> bool

Source§

impl Primality for u32

Source§

const ONE: Self = 0x1

Source§

const FIRST_PRIME: Self = 0x2

Source§

const LAST_PRIME: Self = 0xFFFFFFFB

Source§

fn is_prime(&self) -> bool

Source§

fn strong_case(&self) -> bool

Source§

impl Primality for u64

Source§

const ONE: Self = 0x1

Source§

const FIRST_PRIME: Self = 0x2

Source§

const LAST_PRIME: Self = 0xFFFFFFFFFFFFFFC5

Source§

fn is_prime(&self) -> bool

Source§

fn strong_case(&self) -> bool

Source§

impl Primality for u128

Source§

const ONE: Self = 0x1

Source§

const FIRST_PRIME: Self = 0x2

Source§

const LAST_PRIME: Self = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF61

Source§

fn is_prime(&self) -> bool

Source§

fn strong_case(&self) -> bool

Source§

impl Primality for usize

Source§

const ONE: Self = 0x1

Source§

const FIRST_PRIME: Self = 0x2

Source§

const LAST_PRIME: Self = 0xFFFFFFFFFFFFFFC5

Source§

fn is_prime(&self) -> bool

Source§

fn strong_case(&self) -> bool

Implementors§