pub trait Primes {
    type I: Iterator<Item = Self>;
    type LI: Iterator<Item = Self>;

    // Required methods
    fn primes_less_than(n: &Self) -> Self::LI;
    fn primes_less_than_or_equal_to(n: &Self) -> Self::LI;
    fn primes() -> Self::I;
}

Required Associated Types§

source

type I: Iterator<Item = Self>

source

type LI: Iterator<Item = Self>

Required Methods§

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Primes for u8

source§

fn primes_less_than(n: &u8) -> PrimesLessThanIterator<u8>

Returns an iterator that generates all primes less than a given value.

The iterator produced by primes_less_than(n) generates the same primes as the iterator produced by primes().take_while(|&p| p < n), but the latter would be slower because it doesn’t know in advance how large its prime sieve should be, and might have to create larger and larger prime sieves.

§Worst-case complexity (amortized)

$T(i) = O(\log \log i)$

$M(i) = O(1)$

where $T$ is time, $M$ is additional memory, and $i$ is the iteration index.

§Examples

See here.

source§

fn primes_less_than_or_equal_to(n: &u8) -> PrimesLessThanIterator<u8>

Returns an iterator that generates all primes less than or equal to a given value.

The iterator produced by primes_less_than_or_equal_to(n) generates the same primes as the iterator produced by primes().take_while(|&p| p <= n), but the latter would be slower because it doesn’t know in advance how large its prime sieve should be, and might have to create larger and larger prime sieves.

§Worst-case complexity (amortized)

$T(i) = O(\log \log i)$

$M(i) = O(1)$

where $T$ is time, $M$ is additional memory, and $i$ is the iteration index.

§Examples

See here.

source§

fn primes() -> PrimesIterator<u8>

Returns all primes that fit into the specified type.

The iterator produced by primes(n) generates the same primes as the iterator produced by primes_less_than_or_equal_to(T::MAX). If you really need to generate every prime, and T is u32 or smaller, then you should use the latter, as it will allocate all the needed memory at once. If T is u64 or larger, or if you probably don’t need every prime, then primes() will be faster as it won’t allocate too much memory right away.

§Worst-case complexity (amortized)

$T(i) = O(\log \log i)$

$M(i) = O(1)$

where $T$ is time, $M$ is additional memory, and $i$ is the iteration index.

§Examples

See here.

§

type I = PrimesIterator<u8>

§

type LI = PrimesLessThanIterator<u8>

source§

impl Primes for u16

source§

fn primes_less_than(n: &u16) -> PrimesLessThanIterator<u16>

Returns an iterator that generates all primes less than a given value.

The iterator produced by primes_less_than(n) generates the same primes as the iterator produced by primes().take_while(|&p| p < n), but the latter would be slower because it doesn’t know in advance how large its prime sieve should be, and might have to create larger and larger prime sieves.

§Worst-case complexity (amortized)

$T(i) = O(\log \log i)$

$M(i) = O(1)$

where $T$ is time, $M$ is additional memory, and $i$ is the iteration index.

§Examples

See here.

source§

fn primes_less_than_or_equal_to(n: &u16) -> PrimesLessThanIterator<u16>

Returns an iterator that generates all primes less than or equal to a given value.

The iterator produced by primes_less_than_or_equal_to(n) generates the same primes as the iterator produced by primes().take_while(|&p| p <= n), but the latter would be slower because it doesn’t know in advance how large its prime sieve should be, and might have to create larger and larger prime sieves.

§Worst-case complexity (amortized)

$T(i) = O(\log \log i)$

$M(i) = O(1)$

where $T$ is time, $M$ is additional memory, and $i$ is the iteration index.

§Examples

See here.

source§

fn primes() -> PrimesIterator<u16>

Returns all primes that fit into the specified type.

The iterator produced by primes(n) generates the same primes as the iterator produced by primes_less_than_or_equal_to(T::MAX). If you really need to generate every prime, and T is u32 or smaller, then you should use the latter, as it will allocate all the needed memory at once. If T is u64 or larger, or if you probably don’t need every prime, then primes() will be faster as it won’t allocate too much memory right away.

§Worst-case complexity (amortized)

$T(i) = O(\log \log i)$

$M(i) = O(1)$

where $T$ is time, $M$ is additional memory, and $i$ is the iteration index.

§Examples

See here.

§

type I = PrimesIterator<u16>

§

type LI = PrimesLessThanIterator<u16>

source§

impl Primes for u32

source§

fn primes_less_than(n: &u32) -> PrimesLessThanIterator<u32>

Returns an iterator that generates all primes less than a given value.

The iterator produced by primes_less_than(n) generates the same primes as the iterator produced by primes().take_while(|&p| p < n), but the latter would be slower because it doesn’t know in advance how large its prime sieve should be, and might have to create larger and larger prime sieves.

§Worst-case complexity (amortized)

$T(i) = O(\log \log i)$

$M(i) = O(1)$

where $T$ is time, $M$ is additional memory, and $i$ is the iteration index.

§Examples

See here.

source§

fn primes_less_than_or_equal_to(n: &u32) -> PrimesLessThanIterator<u32>

Returns an iterator that generates all primes less than or equal to a given value.

The iterator produced by primes_less_than_or_equal_to(n) generates the same primes as the iterator produced by primes().take_while(|&p| p <= n), but the latter would be slower because it doesn’t know in advance how large its prime sieve should be, and might have to create larger and larger prime sieves.

§Worst-case complexity (amortized)

$T(i) = O(\log \log i)$

$M(i) = O(1)$

where $T$ is time, $M$ is additional memory, and $i$ is the iteration index.

§Examples

See here.

source§

fn primes() -> PrimesIterator<u32>

Returns all primes that fit into the specified type.

The iterator produced by primes(n) generates the same primes as the iterator produced by primes_less_than_or_equal_to(T::MAX). If you really need to generate every prime, and T is u32 or smaller, then you should use the latter, as it will allocate all the needed memory at once. If T is u64 or larger, or if you probably don’t need every prime, then primes() will be faster as it won’t allocate too much memory right away.

§Worst-case complexity (amortized)

$T(i) = O(\log \log i)$

$M(i) = O(1)$

where $T$ is time, $M$ is additional memory, and $i$ is the iteration index.

§Examples

See here.

§

type I = PrimesIterator<u32>

§

type LI = PrimesLessThanIterator<u32>

source§

impl Primes for u64

source§

fn primes_less_than(n: &u64) -> PrimesLessThanIterator<u64>

Returns an iterator that generates all primes less than a given value.

The iterator produced by primes_less_than(n) generates the same primes as the iterator produced by primes().take_while(|&p| p < n), but the latter would be slower because it doesn’t know in advance how large its prime sieve should be, and might have to create larger and larger prime sieves.

§Worst-case complexity (amortized)

$T(i) = O(\log \log i)$

$M(i) = O(1)$

where $T$ is time, $M$ is additional memory, and $i$ is the iteration index.

§Examples

See here.

source§

fn primes_less_than_or_equal_to(n: &u64) -> PrimesLessThanIterator<u64>

Returns an iterator that generates all primes less than or equal to a given value.

The iterator produced by primes_less_than_or_equal_to(n) generates the same primes as the iterator produced by primes().take_while(|&p| p <= n), but the latter would be slower because it doesn’t know in advance how large its prime sieve should be, and might have to create larger and larger prime sieves.

§Worst-case complexity (amortized)

$T(i) = O(\log \log i)$

$M(i) = O(1)$

where $T$ is time, $M$ is additional memory, and $i$ is the iteration index.

§Examples

See here.

source§

fn primes() -> PrimesIterator<u64>

Returns all primes that fit into the specified type.

The iterator produced by primes(n) generates the same primes as the iterator produced by primes_less_than_or_equal_to(T::MAX). If you really need to generate every prime, and T is u32 or smaller, then you should use the latter, as it will allocate all the needed memory at once. If T is u64 or larger, or if you probably don’t need every prime, then primes() will be faster as it won’t allocate too much memory right away.

§Worst-case complexity (amortized)

$T(i) = O(\log \log i)$

$M(i) = O(1)$

where $T$ is time, $M$ is additional memory, and $i$ is the iteration index.

§Examples

See here.

§

type I = PrimesIterator<u64>

§

type LI = PrimesLessThanIterator<u64>

source§

impl Primes for u128

source§

fn primes_less_than(n: &u128) -> PrimesLessThanIterator<u128>

Returns an iterator that generates all primes less than a given value.

The iterator produced by primes_less_than(n) generates the same primes as the iterator produced by primes().take_while(|&p| p < n), but the latter would be slower because it doesn’t know in advance how large its prime sieve should be, and might have to create larger and larger prime sieves.

§Worst-case complexity (amortized)

$T(i) = O(\log \log i)$

$M(i) = O(1)$

where $T$ is time, $M$ is additional memory, and $i$ is the iteration index.

§Examples

See here.

source§

fn primes_less_than_or_equal_to(n: &u128) -> PrimesLessThanIterator<u128>

Returns an iterator that generates all primes less than or equal to a given value.

The iterator produced by primes_less_than_or_equal_to(n) generates the same primes as the iterator produced by primes().take_while(|&p| p <= n), but the latter would be slower because it doesn’t know in advance how large its prime sieve should be, and might have to create larger and larger prime sieves.

§Worst-case complexity (amortized)

$T(i) = O(\log \log i)$

$M(i) = O(1)$

where $T$ is time, $M$ is additional memory, and $i$ is the iteration index.

§Examples

See here.

source§

fn primes() -> PrimesIterator<u128>

Returns all primes that fit into the specified type.

The iterator produced by primes(n) generates the same primes as the iterator produced by primes_less_than_or_equal_to(T::MAX). If you really need to generate every prime, and T is u32 or smaller, then you should use the latter, as it will allocate all the needed memory at once. If T is u64 or larger, or if you probably don’t need every prime, then primes() will be faster as it won’t allocate too much memory right away.

§Worst-case complexity (amortized)

$T(i) = O(\log \log i)$

$M(i) = O(1)$

where $T$ is time, $M$ is additional memory, and $i$ is the iteration index.

§Examples

See here.

§

type I = PrimesIterator<u128>

§

type LI = PrimesLessThanIterator<u128>

source§

impl Primes for usize

source§

fn primes_less_than(n: &usize) -> PrimesLessThanIterator<usize>

Returns an iterator that generates all primes less than a given value.

The iterator produced by primes_less_than(n) generates the same primes as the iterator produced by primes().take_while(|&p| p < n), but the latter would be slower because it doesn’t know in advance how large its prime sieve should be, and might have to create larger and larger prime sieves.

§Worst-case complexity (amortized)

$T(i) = O(\log \log i)$

$M(i) = O(1)$

where $T$ is time, $M$ is additional memory, and $i$ is the iteration index.

§Examples

See here.

source§

fn primes_less_than_or_equal_to(n: &usize) -> PrimesLessThanIterator<usize>

Returns an iterator that generates all primes less than or equal to a given value.

The iterator produced by primes_less_than_or_equal_to(n) generates the same primes as the iterator produced by primes().take_while(|&p| p <= n), but the latter would be slower because it doesn’t know in advance how large its prime sieve should be, and might have to create larger and larger prime sieves.

§Worst-case complexity (amortized)

$T(i) = O(\log \log i)$

$M(i) = O(1)$

where $T$ is time, $M$ is additional memory, and $i$ is the iteration index.

§Examples

See here.

source§

fn primes() -> PrimesIterator<usize>

Returns all primes that fit into the specified type.

The iterator produced by primes(n) generates the same primes as the iterator produced by primes_less_than_or_equal_to(T::MAX). If you really need to generate every prime, and T is u32 or smaller, then you should use the latter, as it will allocate all the needed memory at once. If T is u64 or larger, or if you probably don’t need every prime, then primes() will be faster as it won’t allocate too much memory right away.

§Worst-case complexity (amortized)

$T(i) = O(\log \log i)$

$M(i) = O(1)$

where $T$ is time, $M$ is additional memory, and $i$ is the iteration index.

§Examples

See here.

§

type I = PrimesIterator<usize>

§

type LI = PrimesLessThanIterator<usize>

Implementors§