From ea0e52e5e9707238215d2f380a8d6bc72956d090 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johanna=20S=C3=B6rng=C3=A5rd?= <44257381+JSorngard@users.noreply.github.com> Date: Wed, 20 Nov 2024 15:16:44 +0100 Subject: [PATCH] Clarify docs of macros (#82) * Clarify docs of macros * There are other usecases than making a constant * `cargo fmt` --- src/generate.rs | 7 ++++++- src/sieve.rs | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/generate.rs b/src/generate.rs index 35b45d5..027d180 100644 --- a/src/generate.rs +++ b/src/generate.rs @@ -236,7 +236,10 @@ pub const fn primes_lt( Ok(primes) } -/// Call [`primes_geq`] or [`primes_lt`], and automatically compute the memory requirement of the sieve. +/// Generate arrays of large prime numbers without having to store all primes +/// from 2 and up in the result, and thus potentially the binary. +/// +/// Calls [`primes_geq`] or [`primes_lt`], and automatically computes the memory requirement of the sieve. /// /// Compute `N` primes larger than or equal to some limit as `primes_segment!(N; >= LIMIT)`, /// and `N` primes less than some limit as `primes_segment!(N; < LIMIT)`. @@ -251,8 +254,10 @@ pub const fn primes_lt( /// # use const_primes::{primes_segment, GenerationError}; /// const N: usize = 3; /// const LIMIT: u64 = 5_000_000_031; +/// /// const PRIMES_GEQ: Result<[u64; N], GenerationError> = primes_segment!(N; >= LIMIT); /// const PRIMES_LT: Result<[u64; N], GenerationError> = primes_segment!(N; < LIMIT); +/// /// // Can also be used at runtime: /// let primes_geq = primes_segment!(N; >= LIMIT); /// diff --git a/src/sieve.rs b/src/sieve.rs index 26eddfc..993278b 100644 --- a/src/sieve.rs +++ b/src/sieve.rs @@ -391,7 +391,10 @@ pub const fn sieve_geq( Ok(ans) } -/// Call [`sieve_geq`] or [`sieve_lt`], and automatically compute the memory requirement of the sieve. +/// Generate arrays of the prime status of large numbers without having to store the prime status +/// of every single integer smaller than the target in the result, and thus potentially the binary. +/// +/// Calls [`sieve_geq`] or [`sieve_lt`], and automatically computes the memory requirement of the sieve. /// /// Sieve the `N` smallest numbers larger than or equal to some limit as `sieve_segment!(N; >= LIMIT)`, /// and the `N` largest numbers smaller than some limit as `sieve_segment!(N; < LIMIT)`.