pub struct Sieve { /* private fields */ }
Expand description

A prime generator, using the Sieve of Eratosthenes method. This is asymptotically more efficient than the Trial Division method, but slower earlier on.

Create with let mut pset = Sieve::new(), and then use pset.iter() to iterate over all primes.

Implementations

A new prime generator, primed with 2 and 3

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Returns the “default value” for a type. Read more

Finds one more prime, and adds it to the list

Return all primes found so far as a slice

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Number of primes found so far

Iterator over all primes not yet found

Iterator over all primes, starting with 2. If you don’t care about the “state” of the PrimeSet, this is what you want! Read more

Iterator over just the primes found so far

Find the next largest prime from a number Read more

Check if a number is prime Read more

Find the next largest prime from a number, if it is within the already-found list Read more

Get the nth prime, even if we haven’t yet found it

Get the prime factors of a number, starting from 2, including repeats

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.