Skip to content

Commit

Permalink
Take SieveFactory by value in sieve_and_find()
Browse files Browse the repository at this point in the history
  • Loading branch information
fjarri committed Nov 13, 2024
1 parent f1821e5 commit 457d1dc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::SieveFactory;
/// Sieves through the results of `sieve_factory` and returns the first item for which `predicate` is `true`.
///
/// If `sieve_factory` signals that no more results can be created, returns `None`.
pub fn sieve_and_find<R, S, T>(rng: &mut R, sieve_factory: &S, predicate: impl Fn(&mut R, &T) -> bool) -> Option<T>
pub fn sieve_and_find<R, S, T>(rng: &mut R, sieve_factory: S, predicate: impl Fn(&mut R, &T) -> bool) -> Option<T>
where
S: SieveFactory<T>,
R: CryptoRngCore,
Expand Down
4 changes: 2 additions & 2 deletions src/presets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ pub fn generate_prime_with_rng<T: Integer + RandomBits + RandomMod>(
rng: &mut impl CryptoRngCore,
bit_length: u32,
) -> T {
sieve_and_find(rng, &SmallPrimesSieveFactory::new(bit_length, false), is_prime_with_rng)
sieve_and_find(rng, SmallPrimesSieveFactory::new(bit_length, false), is_prime_with_rng)
.expect("will produce a result eventually")
}

Expand All @@ -100,7 +100,7 @@ pub fn generate_safe_prime_with_rng<T: Integer + RandomBits + RandomMod>(
) -> T {
sieve_and_find(
rng,
&SmallPrimesSieveFactory::new(bit_length, true),
SmallPrimesSieveFactory::new(bit_length, true),
is_safe_prime_with_rng,
)
.expect("will produce a result eventually")
Expand Down

0 comments on commit 457d1dc

Please sign in to comment.