Skip to content

Commit 1ea01ae

Browse files
committed
Update features doc
1 parent efd3b5c commit 1ea01ae

File tree

2 files changed

+32
-36
lines changed

2 files changed

+32
-36
lines changed

Cargo.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,22 @@ travis-ci = { repository = "rust-random/rand" }
2020
appveyor = { repository = "rust-random/rand" }
2121

2222
[features]
23+
# Meta-features:
2324
default = ["std"] # without "std" rand uses libcore
2425
nightly = ["simd_support"] # enables all features requiring nightly rust
26+
27+
# Optional dependencies:
2528
std = ["rand_core/std", "alloc", "getrandom"]
2629
alloc = ["rand_core/alloc"] # enables Vec and Box support (without std)
27-
i128_support = [] # enables i128 and u128 support
28-
simd_support = ["packed_simd"] # enables SIMD support
2930
serde1 = ["rand_core/serde1", "rand_isaac/serde1", "rand_xorshift/serde1"] # enables serialization for PRNGs
3031
# re-export optional WASM dependencies to avoid breakage:
3132
wasm-bindgen = ["getrandom_package/wasm-bindgen"]
3233
stdweb = ["getrandom_package/stdweb"]
3334
getrandom = ["getrandom_package", "rand_core/getrandom"]
3435

36+
# Configuration:
37+
simd_support = ["packed_simd"] # enables SIMD support
38+
3539
[workspace]
3640
members = [
3741
"rand_core",

README.md

Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -84,41 +84,33 @@ pinned version of Rustc if you require compatibility with a specific version.
8484

8585
## Crate Features
8686

87-
Rand is built with the `std` and `getrandom` features enabled by default:
88-
89-
- `std` enables functionality dependent on the `std` lib and implies `alloc`
90-
and `getrandom`
91-
- `getrandom` is an optional crate, providing the code behind `rngs::OsRng`;
92-
the continued existance of this feature is not guaranteed so users are
93-
encouraged to specify `std` instead
94-
95-
The following optional features are available:
96-
97-
- `alloc` can be used instead of `std` to provide `Vec` and `Box`.
98-
- `log` enables some logging via the `log` crate.
99-
- `nightly` enables all unstable features (`simd_support`).
100-
- `serde1` enables serialization for some types, via Serde version 1.
101-
- `simd_support` enables uniform sampling of SIMD types (integers and floats).
102-
- `stdweb` enables support for `OsRng` on `wasm32-unknown-unknown` via `stdweb`
103-
combined with `cargo-web`.
104-
- `wasm-bindgen` enables support for `OsRng` on `wasm32-unknown-unknown` via
105-
[`wasm-bindgen`]
106-
107-
[`wasm-bindgen`]: https://github.com/rustwasm/wasm-bindgen
108-
109-
`no_std` mode is activated by setting `default-features = false`; this removes
110-
functionality depending on `std`:
111-
112-
- `thread_rng()`, and `random()` are not available, as they require thread-local
113-
storage and an entropy source.
114-
- Since no external entropy is available, it is not possible to create
115-
generators with fresh seeds using the `FromEntropy` trait (user must provide
116-
a seed).
117-
- Several non-linear distributions distributions are unavailable since `exp`
118-
and `log` functions are not provided in `core`.
119-
- Large parts of the `seq`-uence module are unavailable, unless the `alloc`
120-
feature is used (several APIs and many implementations require `Vec`).
87+
Rand is built with these features enabled by default:
12188

89+
- `std` enables functionality dependent on the `std` lib
90+
- `alloc` (implied by `std`) enables functionality requiring an allocator
91+
- `getrandom` (implied by `std`) is an optional dependency providing the code
92+
behind `rngs::OsRng`
93+
94+
Optionally, the following dependencies can be enabled:
95+
96+
- `log` enables logging via the `log` crate
97+
- `serde1` enables serialization for some types, via Serde version 1
98+
- `stdweb` implies `getrandom/stdweb` to enable
99+
`getrandom` support on `wasm32-unknown-unknown`
100+
- `wasm-bindgen` implies `getrandom/wasm-bindgen` to enable
101+
`getrandom` support on `wasm32-unknown-unknown`
102+
103+
Additionally, these features configure Rand:
104+
105+
- `nightly` enables all experimental features
106+
- `simd_support` (experimental) enables sampling of SIMD values
107+
(uniformly random SIMD integers and floats)
108+
109+
Rand supports limited functionality in `no_std` mode (enabled via
110+
`default-features = false`). In this case, `OsRng` and `from_entropy` are
111+
unavailable (unless `getrandom` is enabled), large parts of `seq` are
112+
unavailable (unless `alloc` is enabled), and `thread_rng` and `random` are
113+
unavailable.
122114

123115
# License
124116

0 commit comments

Comments
 (0)