Crate const_primes

source ·
Expand description

A crate for generating arrays of prime numbers at compile time.

The crate currently uses trial division to compute primes and generation of very large arrays will therefore take a long time.

#![no_std] compatible.

Example

const PRIMES: Primes<10> = Primes::new();
assert_eq!(PRIMES[5], 13);
assert_eq!(PRIMES, [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]);

Structs

  • A wrapper around an array that consists of the first N primes and can be created in const contexts.