This reverts a change from #979 that introduced a massive performance
regression by disabling SIMD for `rand_chacha`.
Likely, the behavior of `ppv-lite86` should rather be fixed. This change
serves as a workaround until a fixed version is available.
Fixes#1017.
The corresponds more closely to the internally used types and can be
easily converted to a `char` via `From` and `Into`, while being more
flexible to use.
This is a breaking change.
Sampling a random alphanumeric string by collecting chars (that are known to be ASCII) into a String involves re-allocation as String is encoding to UTF-8, via the example:
```rust
let chars: String = iter::repeat(())
.map(|()| rng.sample(Alphanumeric))
.take(7)
.collect();
```
I wanted to get rid of the clearly unnecessary re-allocations in my applications, so I needed to be able to access to the ASCII characters as simple bytes. It seems like that was already what was going on inside Alphanumeric however, it was just internal.
This PR changes the `Distribution<char>` impl to provide `u8`s (which it generates internally) instead, and implements the previous `Distribution<char>` using it. One could then, for example, do this:
```rust
let mut rng = thread_rng();
let bytes = (0..7).map(|_| rng.sample(ByteAlphanumeric)).collect();
let chars = unsafe { String::from_utf8_unchecked(bytes) };
```
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.
* replace custom Float trait with num-traits::Float
* enable no_std support via num-traits math functions
* remove Distribution<u64> impl for poisson
* move stability tests
* add copyright notice
* tweak dirichlet and alias_method to use boxed slice instead of vec
This fixes a clippy warning and slightly improves ergonomic.
This is technically a breaking change, but it is unlikely to break code
in practice, since `IntoIterator` is in Rust's prelude.