From fd8b066641e935afd108d0f6697ad2eaa0298fe0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johanna=20S=C3=B6rng=C3=A5rd?= Date: Fri, 10 May 2024 12:32:44 +0200 Subject: [PATCH] Gave modules more descriptive names --- src/{imath.rs => integer_math.rs} | 0 src/lib.rs | 20 +++++++++---------- ...{miller_rabin.rs => primality_checking.rs} | 2 +- src/{primes_cache.rs => prime_cache.rs} | 0 src/{counting.rs => prime_counting.rs} | 0 src/{generation.rs => prime_generation.rs} | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) rename src/{imath.rs => integer_math.rs} (100%) rename src/{miller_rabin.rs => primality_checking.rs} (98%) rename src/{primes_cache.rs => prime_cache.rs} (100%) rename src/{counting.rs => prime_counting.rs} (100%) rename src/{generation.rs => prime_generation.rs} (99%) diff --git a/src/imath.rs b/src/integer_math.rs similarity index 100% rename from src/imath.rs rename to src/integer_math.rs diff --git a/src/lib.rs b/src/lib.rs index 0e1e4d7..d7468b2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -109,20 +109,20 @@ // This is used since there is currently no way to be generic over types that can do arithmetic at compile time. type Underlying = u32; -mod counting; -mod generation; -mod imath; -mod miller_rabin; +mod prime_counting; +mod prime_generation; +mod integer_math; mod other_prime; -mod primes_cache; +mod primality_checking; +mod prime_cache; mod sieving; -pub use counting::count_primes; -pub use generation::{primes, primes_geq, primes_lt, GenerationError}; -pub use imath::isqrt; -pub use miller_rabin::is_prime; +pub use prime_counting::count_primes; +pub use prime_generation::{primes, primes_geq, primes_lt, GenerationError}; +pub use integer_math::isqrt; pub use other_prime::{next_prime, previous_prime}; -pub use primes_cache::Primes; +pub use primality_checking::is_prime; +pub use prime_cache::Primes; pub use sieving::{sieve, sieve_geq, sieve_lt, SieveError}; #[cfg(test)] diff --git a/src/miller_rabin.rs b/src/primality_checking.rs similarity index 98% rename from src/miller_rabin.rs rename to src/primality_checking.rs index 7f28ada..5b37b86 100644 --- a/src/miller_rabin.rs +++ b/src/primality_checking.rs @@ -1,6 +1,6 @@ //! This module contains an implementation of a deterministic Miller-Rabin primality test -use crate::imath::{mod_mul, mod_pow}; +use crate::integer_math::{mod_mul, mod_pow}; /// Returns whether `n` is prime. /// diff --git a/src/primes_cache.rs b/src/prime_cache.rs similarity index 100% rename from src/primes_cache.rs rename to src/prime_cache.rs diff --git a/src/counting.rs b/src/prime_counting.rs similarity index 100% rename from src/counting.rs rename to src/prime_counting.rs diff --git a/src/generation.rs b/src/prime_generation.rs similarity index 99% rename from src/generation.rs rename to src/prime_generation.rs index 6834a34..eb9fcf3 100644 --- a/src/generation.rs +++ b/src/prime_generation.rs @@ -419,7 +419,7 @@ impl fmt::Display for GenerationError { ), Self::SieveOverrun(number) => write!( f, - "encountered the number {number} which would have needed `MEM` to be at least {} to sieve", crate::imath::isqrt(*number) + 1 + "encountered the number {number} which would have needed `MEM` to be at least {} to sieve", crate::integer_math::isqrt(*number) + 1 ), Self::OutOfPrimes => write!(f, "ran out of primes before the array was filled"), }