This PR removes the hacky `impl_try_rng_from_rng_core` and
`impl_try_crypto_rng_from_crypto_rng` macros and replaces them with
blanket impls of `TryRngCore` for `RngCore` and `TryCryptoRng` for
`CryptoRng`.
This change means that `TryRngCore`/`TryCryptoRng` no longer can have
blanket impls for `&mut R` and `Box<R>`. But I think it should be
tolerable since most users will be using `RngCore`/`CryptoRng`, which
have blanket impl for `DerefMut` (it covers both `&mut R` and `Box<R>`).
* Simplify redundant doc-link
* Remove impl of SeedableRng for SmallRng
* Fix SeedableRng::Seed type for StdRng
* SmallRng: do not expect thread_rng
* Make SmallRng::from_thread_rng infallible
* Fix benchmarks (SmallRng does not have from_entropy)
* Forbid unsafe code in crates without unsafe code
This helps tools like `cargo geiger`.
* Make `Uniform` constructors return a result
- This is a breaking change.
- The new error type had to be made public, otherwise `Uniform` could
not be extended for user-defined types by implementing
`UniformSampler`.
- `rand_distr` was updated accordingly.
- Also forbid unsafe code for crates where none is used.
Fixes#1195, #1211.
* Address review feedback
* Make `sample_single` return a `Result`
* Fix benchmarks
* Small fixes
* Update src/distributions/uniform.rs
* Made shuffle and partial_shuffle faster
* Use criterion benchmarks for shuffle
* Added a note about RNG word size
* Tidied comments
* Added a debug_assert
* Added a comment re possible further optimization
* Added and updated copyright notices
* Revert cfg mistake
* Reverted change to mod.rs
* Removed ChaCha20 benches from shuffle
* moved debug_assert out of a const fn
* Added new versions of choose and choose_stable
* Removed coin_flipper tests which were unnecessary and not building on ci
* Performance optimizations in coin_flipper
* Clippy fixes and more documentation
* Added a correctness fix for coin_flipper
* Update benches/seq.rs
Co-authored-by: Vinzent Steinberg <Vinzent.Steinberg@gmail.com>
* Update benches/seq.rs
Co-authored-by: Vinzent Steinberg <Vinzent.Steinberg@gmail.com>
* Removed old version of choose and choose stable and updated value stability tests
* Moved sequence choose benchmarks to their own file
* Reworked coin_flipper
* Use criterion for seq_choose benches
* Removed an old comment
* Change how c is estimated in coin_flipper
* Revert "Use criterion for seq_choose benches"
This reverts commit 23395391370ab95694558be90686eb16494e590a.
* Added seq_choose benches for smaller numbers
* Removed some unneeded lines from seq_choose
* Improvements in coin_flipper.rs
* Small refactor of coin_flipper
* Tidied comments in coin_flipper
* Use criterion for seq_choose benchmarks
* Made choose not generate a random number if len=1
* small change to IteratorRandom::choose
* Made it easier to change seq_choose benchmarks RNG
* Added Pcg64 benchmarks for seq_choose
* Added TODO to coin_flipper
* Changed criterion settings in seq_choose
Co-authored-by: Vinzent Steinberg <Vinzent.Steinberg@gmail.com>
- using min_const_gen on no_std fails to compile because of a bad import
- sample_efraimidis_spirakis only requires alloc but it was marked with
a std requirement
This adds support for `Rng::range(a..b)` and `Rng::range(a..=b)`,
replacing `Rng::range(a, b)`. `a` and `b` must now implement
`PartialEq`.
This is a breaking change. In most cases, replacing
`Rng::gen_range(a, b)` with `Rng::gen_range(a..b)` should be enough,
however type annotations may be necessary, and `a` and `b` can no longer
be references or SIMD types.
SIMD types are still supported by `UniformSampler::sample_single`.
Some clippy warnings were fixed as well.