pub trait PrimeSet: PrimeSetBasics + Sized {
    fn len(&self) -> usize { ... }
    fn is_empty(&self) -> bool { ... }
    fn generator(&mut self) -> PrimeSetIter<'_, Self>Notable traits for PrimeSetIter<'a, P>impl<'a, P: PrimeSet> Iterator for PrimeSetIter<'a, P>    type Item = u64; { ... }
    fn iter(&mut self) -> PrimeSetIter<'_, Self>Notable traits for PrimeSetIter<'a, P>impl<'a, P: PrimeSet> Iterator for PrimeSetIter<'a, P>    type Item = u64; { ... }
    fn iter_vec(&self) -> Iter<'_, u64> { ... }
    fn find(&mut self, n: u64) -> (usize, u64) { ... }
    fn is_prime(&mut self, n: u64) -> bool { ... }
    fn find_vec(&self, n: u64) -> Option<(usize, u64)> { ... }
    fn get(&mut self, index: usize) -> u64 { ... }
    fn prime_factors(&mut self, n: u64) -> Vec<u64> { ... }
}

Provided Methods

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!

Iterator over just the primes found so far

Find the next largest prime from a number

Returns (idx, prime)

Note that if n is prime, then the output will be (idx, n)

Check if a number is prime

Note that this only requires primes up to n.sqrt() to be generated, and will generate them as necessary on its own.

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

Returns (idx, prime)

Note that if n is prime, then the output will be (idx, n)

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

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

Implementors