* impl TrustedLen is unsafe
Implementing `TrustedLen` is now unsafe.
From what I understand, quite a few people are still unhappy about the design since the `unsafe` marker in this case is a promise that `size_hint()` in a *different* impl is accurate, so this may change again.
Anyway, we need to do something to fix our builds, and the alternative is just to remove this (I haven't a clue if it is enabling any important optimisations).
* Remove TrustedLen impl for DistIter
It reads "For ChaCha and Hc128 this is a maximum of fifteen `u32` values before
reseeding" while rand_chacha v0.2.0 or higher actually consumes 63 `u32` values
before reseeding.
The main change is that Dirichlet now has a const trait N for
the dimension. The other significant change is to propagate
errors that could occur when Beta:new or Gamma::new is called.
* Create a struct for each random variate generation method:
DirichletFromGamma and DirichletFromBeta.
* Move the initialization of the data required by the generators
into the new() method.
* Make the main Dirichlet object an enum.
* 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>
The previous implementation used either `Vec::insert` or a second
F-Y shuffling phase to achieve fair random order. Instead, use the
random numbers already drawn to achieve a fair shuffle.
* Bump MSRV to 1.56 (Edition 2021)
* Apply Clippy suggestions
* Bump edition and add rust-version field to Cargo.toml
* CI AVR test: unpin nightly rust version
* Disable AVR test
* Bump crate version numbers for a breaking release
* examples/rayon-monte-carlo.rs: remove execute bit of file metadata
* Document in README that MSRV is 1.51.0
This was changed in #1246
* Update GitHub Actions