Skip to content

Commit 4dd6216

Browse files
authored
Add example of next_prime(u64::MAX)
1 parent 656ff88 commit 4dd6216

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,17 @@ Use `is_prime` to test whether a given number is prime:
8989
const CHECK: bool = is_prime(18_446_744_073_709_551_557);
9090
assert!(CHECK);
9191
```
92-
Find the next or previous prime numbers with `next_prime` and `previous_prime` if they exist:
92+
Find the next or previous prime numbers with `next_prime` and `previous_prime` if they exist and can be represented in a `u64`:
9393
```rust
9494
const NEXT: Option<u64> = next_prime(25);
9595
const PREV: Option<u64> = previous_prime(25);
96-
const NOSUCH: Option<u64> = previous_prime(2);
96+
const NO_SUCH: Option<u64> = previous_prime(2);
97+
const TOO_BIG: Option<u64> = next_prime(u64::MAX);
9798

9899
assert_eq!(NEXT, Some(29));
99100
assert_eq!(PREV, Some(23));
100-
assert_eq!(NOSUCH, None);
101+
assert_eq!(NO_SUCH, None);
102+
assert_eq!(TOO_BIG, None);
101103
```
102104
and more!
103105

0 commit comments

Comments
 (0)