[][src]Struct primal::Primes

pub struct Primes { /* fields omitted */ }

An iterator over all primes.

This will yield primes indefinitely (bits in usize permitting). If there is an known upper bound, sieving first with Sieve and using its primes_from method may be more efficient, especially if the bound is small.

This requires O(sqrt(p)) memory to yield prime p, where X is the maximum value of usize.

Examples

let count = primal::Primes::all().take_while(|p| *p < 1_000_000).count();
println!("{}", count);

Implementations

impl Primes[src]

pub fn all() -> Primes[src]

The sequence 2, 3, 5, 7, 11, ....

Examples

// print the first 20 primes
for p in primal::Primes::all().take(20) {
    println!("{}", p);
}

Trait Implementations

impl Iterator for Primes[src]

type Item = usize

The type of the elements being iterated over.

Auto Trait Implementations

impl RefUnwindSafe for Primes

impl Send for Primes

impl Sync for Primes

impl Unpin for Primes

impl UnwindSafe for Primes

Blanket Implementations

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

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

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

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

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

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

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.