mirror of
https://github.com/rust-random/rand
synced 2024-10-18 13:52:51 +00:00
Update features doc
This commit is contained in:
parent
efd3b5c964
commit
1ea01ae80e
|
@ -20,18 +20,22 @@ travis-ci = { repository = "rust-random/rand" }
|
||||||
appveyor = { repository = "rust-random/rand" }
|
appveyor = { repository = "rust-random/rand" }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
# Meta-features:
|
||||||
default = ["std"] # without "std" rand uses libcore
|
default = ["std"] # without "std" rand uses libcore
|
||||||
nightly = ["simd_support"] # enables all features requiring nightly rust
|
nightly = ["simd_support"] # enables all features requiring nightly rust
|
||||||
|
|
||||||
|
# Optional dependencies:
|
||||||
std = ["rand_core/std", "alloc", "getrandom"]
|
std = ["rand_core/std", "alloc", "getrandom"]
|
||||||
alloc = ["rand_core/alloc"] # enables Vec and Box support (without std)
|
alloc = ["rand_core/alloc"] # enables Vec and Box support (without std)
|
||||||
i128_support = [] # enables i128 and u128 support
|
|
||||||
simd_support = ["packed_simd"] # enables SIMD support
|
|
||||||
serde1 = ["rand_core/serde1", "rand_isaac/serde1", "rand_xorshift/serde1"] # enables serialization for PRNGs
|
serde1 = ["rand_core/serde1", "rand_isaac/serde1", "rand_xorshift/serde1"] # enables serialization for PRNGs
|
||||||
# re-export optional WASM dependencies to avoid breakage:
|
# re-export optional WASM dependencies to avoid breakage:
|
||||||
wasm-bindgen = ["getrandom_package/wasm-bindgen"]
|
wasm-bindgen = ["getrandom_package/wasm-bindgen"]
|
||||||
stdweb = ["getrandom_package/stdweb"]
|
stdweb = ["getrandom_package/stdweb"]
|
||||||
getrandom = ["getrandom_package", "rand_core/getrandom"]
|
getrandom = ["getrandom_package", "rand_core/getrandom"]
|
||||||
|
|
||||||
|
# Configuration:
|
||||||
|
simd_support = ["packed_simd"] # enables SIMD support
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
members = [
|
members = [
|
||||||
"rand_core",
|
"rand_core",
|
||||||
|
|
50
README.md
50
README.md
|
@ -84,41 +84,33 @@ pinned version of Rustc if you require compatibility with a specific version.
|
||||||
|
|
||||||
## Crate Features
|
## Crate Features
|
||||||
|
|
||||||
Rand is built with the `std` and `getrandom` features enabled by default:
|
Rand is built with these features enabled by default:
|
||||||
|
|
||||||
- `std` enables functionality dependent on the `std` lib and implies `alloc`
|
- `std` enables functionality dependent on the `std` lib
|
||||||
and `getrandom`
|
- `alloc` (implied by `std`) enables functionality requiring an allocator
|
||||||
- `getrandom` is an optional crate, providing the code behind `rngs::OsRng`;
|
- `getrandom` (implied by `std`) is an optional dependency providing the code
|
||||||
the continued existance of this feature is not guaranteed so users are
|
behind `rngs::OsRng`
|
||||||
encouraged to specify `std` instead
|
|
||||||
|
|
||||||
The following optional features are available:
|
Optionally, the following dependencies can be enabled:
|
||||||
|
|
||||||
- `alloc` can be used instead of `std` to provide `Vec` and `Box`.
|
- `log` enables logging via the `log` crate
|
||||||
- `log` enables some logging via the `log` crate.
|
- `serde1` enables serialization for some types, via Serde version 1
|
||||||
- `nightly` enables all unstable features (`simd_support`).
|
- `stdweb` implies `getrandom/stdweb` to enable
|
||||||
- `serde1` enables serialization for some types, via Serde version 1.
|
`getrandom` support on `wasm32-unknown-unknown`
|
||||||
- `simd_support` enables uniform sampling of SIMD types (integers and floats).
|
- `wasm-bindgen` implies `getrandom/wasm-bindgen` to enable
|
||||||
- `stdweb` enables support for `OsRng` on `wasm32-unknown-unknown` via `stdweb`
|
`getrandom` support on `wasm32-unknown-unknown`
|
||||||
combined with `cargo-web`.
|
|
||||||
- `wasm-bindgen` enables support for `OsRng` on `wasm32-unknown-unknown` via
|
|
||||||
[`wasm-bindgen`]
|
|
||||||
|
|
||||||
[`wasm-bindgen`]: https://github.com/rustwasm/wasm-bindgen
|
Additionally, these features configure Rand:
|
||||||
|
|
||||||
`no_std` mode is activated by setting `default-features = false`; this removes
|
- `nightly` enables all experimental features
|
||||||
functionality depending on `std`:
|
- `simd_support` (experimental) enables sampling of SIMD values
|
||||||
|
(uniformly random SIMD integers and floats)
|
||||||
- `thread_rng()`, and `random()` are not available, as they require thread-local
|
|
||||||
storage and an entropy source.
|
|
||||||
- Since no external entropy is available, it is not possible to create
|
|
||||||
generators with fresh seeds using the `FromEntropy` trait (user must provide
|
|
||||||
a seed).
|
|
||||||
- Several non-linear distributions distributions are unavailable since `exp`
|
|
||||||
and `log` functions are not provided in `core`.
|
|
||||||
- Large parts of the `seq`-uence module are unavailable, unless the `alloc`
|
|
||||||
feature is used (several APIs and many implementations require `Vec`).
|
|
||||||
|
|
||||||
|
Rand supports limited functionality in `no_std` mode (enabled via
|
||||||
|
`default-features = false`). In this case, `OsRng` and `from_entropy` are
|
||||||
|
unavailable (unless `getrandom` is enabled), large parts of `seq` are
|
||||||
|
unavailable (unless `alloc` is enabled), and `thread_rng` and `random` are
|
||||||
|
unavailable.
|
||||||
|
|
||||||
# License
|
# License
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue