pub trait PrimeBuffer<'a> {
    type PrimeIter: Iterator<Item = &'a u64>;

    fn iter(&'a self) -> Self::PrimeIter;
    fn reserve(&mut self, limit: u64);
    fn bound(&self) -> u64;
    fn contains(&self, num: u64) -> bool;
    fn clear(&mut self);
}
Expand description

This trait represents a general data structure that stores primes.

It’s recommended to store at least a bunch of small primes in the buffer to make some of the algorithms more efficient.

Required Associated Types

Required Methods

Directly return an iterator of existing primes

Generate primes until the largest prime in the buffer is equal or larger than limit

Get the largest primes in the list

Test if the number is in the buffer. If a number is not in the buffer, then it’s either a composite or large than PrimeBuffer::bound()

clear the prime buffer to save memory

Implementors