const_primes

Function next_prime

Source
pub const fn next_prime(n: u64) -> Option<u64>
Expand description

Returns the smallest prime greater than n if there is one that can be represented by a u64.

Scans for primes upwards from the input with is_prime.

ยงExample

Basic usage:

const NEXT: Option<u64> = next_prime(400);
assert_eq!(NEXT, Some(401));

Primes larger than 18446744073709551557 can not be represented by a u64:

const NO_SUCH: Option<u64> = next_prime(18_446_744_073_709_551_557);
assert_eq!(NO_SUCH, None);