Skip to content

Commit 071c350

Browse files
authored
Clearer macro docs (#83)
* Update README.md * Remove less important example * Update lib.rs * Update lib.rs * Update README.md * Update lib.rs * cargo update
1 parent eb562ef commit 071c350

File tree

3 files changed

+28
-58
lines changed

3 files changed

+28
-58
lines changed

Cargo.lock

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,6 @@ assert!(CACHE.is_prime(1000).is_none());
4747
assert!(CACHE.count_primes_leq(1000).is_none());
4848
```
4949

50-
Want only the numbers? Use the `primes` function, or convert the cache into an array:
51-
52-
```rust
53-
use const_primes::{primes, Primes};
54-
55-
const CACHE: Primes<10> = Primes::new();
56-
57-
const PRIMES_ARRAY1: [u32; 10] = primes();
58-
const PRIMES_ARRAY2: [i32; 10] = PRIMES.into_array();
59-
60-
assert_eq!(PRIMES_ARRAY1, [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]);
61-
assert_eq!(PRIMES_ARRAY1, PRIMES_ARRAY2);
62-
```
63-
6450
## Example: primality checking
6551

6652
Use `is_prime` to test whether a given number is prime:
@@ -75,13 +61,11 @@ assert!(CHECK);
7561

7662
## Example: generate the three primes after 5000000031
7763

78-
The crate also provides prime generation and sieving functions that can be used
79-
to work with ranges of large numbers that don't start at zero, e.g.
80-
`primes_geq` and `sieve_lt`. These functions can use large sieves to compute
81-
large primes, but don't need to return the entire sieve, just the requested numbers.
82-
They are most conveniently used through the macros `primes_segment!` and
83-
`sieve_segment!` that automatically compute the size of the sieve that's needed
84-
for a certain computation.
64+
The crate also provides prime generation and sieving functionality for computing arrays of
65+
large prime numbers above or below some limit, without having to also include every single prime number from 2 and up in the
66+
resulting constant, and thus potentially the binary.
67+
This functionality is most conveniently accessed through the macros `primes_segment!` and
68+
`sieve_segment!` that automatically compute the size of the prime sieve that is needed for a certain computation.
8569

8670
Compute 3 primes greater than or equal to 5000000031:
8771

src/lib.rs

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,6 @@
3737
//! assert!(CACHE.prime_pi(1000).is_none());
3838
//! ```
3939
//!
40-
//! Want only the numbers? Use the function [`primes`], or convert the cache into an array:
41-
//!
42-
//! ```
43-
//! use const_primes::{primes, Primes};
44-
//!
45-
//! const CACHE: Primes<10> = Primes::new();
46-
//!
47-
//! const PRIMES_ARRAY1: [u32; 10] = primes();
48-
//! const PRIMES_ARRAY2: [u32; 10] = CACHE.into_array();
49-
//!
50-
//! assert_eq!(PRIMES_ARRAY1, [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]);
51-
//! assert_eq!(PRIMES_ARRAY1, PRIMES_ARRAY2);
52-
//! ```
53-
//!
5440
//! # Example: primality checking
5541
//!
5642
//! Use [`is_prime`] to test whether a given number is prime:
@@ -65,14 +51,14 @@
6551
//!
6652
//! # Example: generate the three primes after 5000000031
6753
//!
68-
//! The crate also provides prime generation and sieving functions that can be used to work
69-
//! with ranges of large numbers that don't start at zero, e.g. `primes_geq` and `sieve_lt`.
70-
//! These functions can use large sieves to compute large primes,
71-
//! but don't need to return the entire sieve, just the requested numbers.
72-
//! They are most conveniently used through the macros `primes_segment!` and `sieve_segment!`
73-
//! that automatically compute the size of the sieve that's needed for a certain computation.
54+
//! The crate also provides prime generation and sieving functionality for computing arrays of large
55+
//! prime numbers above or below some limit, without having to also include every single prime number from 2 and up in the
56+
//! resulting constant, and thus potentially the binary.
57+
//! This functionality is most conveniently accessed through the macros [`primes_segment!`] and
58+
//! [`sieve_segment!`] that automatically compute the size of the prime sieve that is needed
59+
//! for a certain computation.
7460
//!
75-
//! Compute 3 primes greater than or equal to 5000000031:
61+
//! Compute the three primes greater than or equal to 5000000031:
7662
//!
7763
//! ```
7864
//! use const_primes::{primes_segment, GenerationError};

0 commit comments

Comments
 (0)