From 99648b69ad8db55a151e6a5ee9914f4221cb881b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johanna=20S=C3=B6rng=C3=A5rd?= Date: Wed, 20 Nov 2024 15:14:30 +0100 Subject: [PATCH 1/3] Clarify docs of macros --- 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..a7e4ce1 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 constant, and thus 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..7435eb4 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 resulting constant, and thus 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)`. From 91fa64ee434b8031e8c510e4343b588c82a85c4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johanna=20S=C3=B6rng=C3=A5rd?= Date: Wed, 20 Nov 2024 15:15:39 +0100 Subject: [PATCH 2/3] There are other usecases than making a constant --- src/generate.rs | 2 +- src/sieve.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/generate.rs b/src/generate.rs index a7e4ce1..cadb49e 100644 --- a/src/generate.rs +++ b/src/generate.rs @@ -237,7 +237,7 @@ pub const fn primes_lt( } /// Generate arrays of large prime numbers without having to store all primes -/// from 2 and up in the constant, and thus the binary. +/// 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. /// diff --git a/src/sieve.rs b/src/sieve.rs index 7435eb4..78f0fa5 100644 --- a/src/sieve.rs +++ b/src/sieve.rs @@ -392,7 +392,7 @@ pub const fn sieve_geq( } /// 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 resulting constant, and thus the binary. +/// 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. /// From 364d13e1fcb01712175f646e0595b3ebb9c15159 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johanna=20S=C3=B6rng=C3=A5rd?= Date: Wed, 20 Nov 2024 15:16:08 +0100 Subject: [PATCH 3/3] `cargo fmt` --- src/generate.rs | 6 +++--- src/sieve.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/generate.rs b/src/generate.rs index cadb49e..027d180 100644 --- a/src/generate.rs +++ b/src/generate.rs @@ -238,7 +238,7 @@ pub const fn primes_lt( /// 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)`, @@ -254,10 +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 78f0fa5..993278b 100644 --- a/src/sieve.rs +++ b/src/sieve.rs @@ -393,7 +393,7 @@ pub const fn sieve_geq( /// 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)`,