Function
find_primes
(start: u32, count: usize, buffer: &mut [u32])
Source from the content-addressed store, hash-verified
| 20 | } |
| 21 | |
| 22 | fn find_primes(start: u32, count: usize, buffer: &mut [u32]) -> usize { |
| 23 | let mut found = 0; |
| 24 | let mut candidate = if start % 2 == 0 { start + 1 } else { start }; |
| 25 | |
| 26 | while found < count && found < buffer.len() { |
| 27 | if is_prime(candidate) { |
| 28 | buffer[found] = candidate; |
| 29 | found += 1; |
| 30 | } |
| 31 | candidate += 2; |
| 32 | } |
| 33 | |
| 34 | found |
| 35 | } |
| 36 | |
| 37 | fn main() { |
| 38 | let mut primes = [0u32; 10]; |
Tested by
no test coverage detected