Skip to content

Commit

Permalink
Clarify docs of macros (#82)
Browse files Browse the repository at this point in the history
* Clarify docs of macros

* There are other usecases than making a constant

* `cargo fmt`
  • Loading branch information
JSorngard authored Nov 20, 2024
1 parent e0a33d5 commit ea0e52e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,10 @@ pub const fn primes_lt<const N: usize, const MEM: usize>(
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)`.
Expand All @@ -251,8 +254,10 @@ pub const fn primes_lt<const N: usize, const MEM: usize>(
/// # 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);
///
Expand Down
5 changes: 4 additions & 1 deletion src/sieve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,10 @@ pub const fn sieve_geq<const N: usize, const MEM: usize>(
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)`.
Expand Down

0 comments on commit ea0e52e

Please sign in to comment.