This file contains the changes to the crate since version 0.4.8.
- Make links to crates in the docs on docs.rs link to the docs of those crates on docs.rs.
- Added the
fast_test
feature that makesis_prime
call out to themachine-prime
crate for a significant speedup.
- Correct function name in README.
- Set
rust-version
to 1.81.0. It is not an MSRV guarantee for the future. It is done because crates.io now auto sets it to the first version on the given edition if you do not set anything. For this crate that would be 1.56.0, which is too old to compile it.
- Documentation improvements for the macros.
- Clarified which crate versions have which MSRVs.
- Corrected docstring of
Primes<N>
.
- Corrected docstring of
Primes<N>::default
. - Corrected docstring of
Primes<N>::new
.
- Removed the
const_assert
feature, its functionality is now always enabled. - Removed the
std
feature, the crate now uses theError
trait fromcore
. The crate is thus alwaysno_std
compatible. If theserde
feature is enabled the crate uses theserde_arrays
crate to serialize the type, and that crate in turn uses the standard library. - Replaced the implementations of
PartialEq
,Eq
,PartialOrd
, andOrd
onPrimes
with just the default derives. To perform comparisons of the numbers in the struct with arrays or slices you can callas_array
oras_slice
. - Renamed the
count_primes_leq
function to the more expected nameprime_pi
These changes mean that the MSRV of the crate is increased from 1.67.1 to 1.81.0.
- Added the
zerocopy
feature that derives theIntoBytes
trait from thezerocopy
crate for thePrimes
struct. - Added the
rkyv
feature that derives theSerialize
,Deserialize
, andArchive
traits from therkyv
crate for thePrimes
struct.
- Sped up
is_prime
by checking fewer witnesses in the Miller-Rabin test.
- Fixed a bug where the crate would try to sieve numbers below zero for some
inputs to
sieve_lt
andprimes_lt
and panic.
- Added the
const_assert
feature that promotes all panics that involve only const generics into compile errors.
- License and docs.rs link improvements in README.
- Minor documentation improvements.
- Added the
totient
function to thePrimes
struct. - Derived
Serialize
andDeserialize
for the error types. - Derived
Hash
forSieveError
.
- Added the
serde
feature that derives theSerialize
andDeserialize
traits fromserde
for thePrimes
struct.
- Added a crate feature flag badge to the docs.
- Mention what can be done with the crate clearer in the description.
- Changed
Primes<N>::binary_search
to have the same API asslice::binary_search
.
- Corrected wrong doclink to
remainder
in docstring ofPrimes<N>::prime_factors
.
- Added
Primes<N>::prime_factors
function that returns an iterator over the prime factors of the given number (and not their multiplicities).
- Added
Primes<N>::prime_factorization
function that returns an iterator over the prime factors of the given number and their multiplicities.
- Organized the examples in the readme and top level crate documentation in a clearer way.
PrimesIter
no longer takes a const generic.
- Minor documentation tweaks.
- Corrected MSRV to 1.67.1.
- Made the
Primes<N>::iter
function and theIntoIterator
implementation forPrimes<N>
return custom iterator types. Allows less disruptive refactoring in the future.
- Removed panics in functions (like
primes
) whenN
is zero. It results in an empty array, but may be what you want.
- Implemented
IntoIterator
for&Primes<N>
.
This version focuses on adding support for generating primes and sieving numbers in arbitrary ranges, instead of always having to start from 0. It also shortens and clarifies some function names.
- Renamed
are_prime
tosieve
. - Renamed
are_prime_below
tosieve_lt
. - Changed function signature of
sieve_lt
. - Renamed
largest_prime_leq
toprevious_prime
. - Renamed
smallest_prime_lt
tonext_prime
. - Renamed
prime_counts
tocount_primes
. - Removed
moebius
, as it is out of scope of this crate. If you want the source code for that function it can be found on Rosettacode, or in older versions of this crate.
- Added
primes_geq
,primes_lt
, andsieve_geq
functions to work with arbitrary ranges. They take two const generics, the number of values to return and the size of the sieve used during evaluation. - Added
primes_segment!
andsieve_segment!
macros to simplify usage of the above functions. These macros compute the size of the sieve that the above functions need. Due to restrictions on const arithmetic this can not be done inside the functions. - Added
isqrt
function. This can be useful if you wish to compute the size of the sieve yourself.
- Speed up
PRIMES::count_primes_leq
by using a binary instead of linear search. - Various documentation improvements.