5d2dcb5b73
This aligns us with Servo. It pulls a new `rand` crate version, but I'm removing one in https://phabricator.services.mozilla.com/D55351, so hopefully adds up :) Differential Revision: https://phabricator.services.mozilla.com/D55359 --HG-- rename : third_party/rust/cssparser-macros/Cargo.toml => third_party/rust/phf_macros/Cargo.toml rename : third_party/rust/cssparser-macros/Cargo.toml => third_party/rust/proc-macro-hack/Cargo.toml rename : third_party/rust/rand/.cargo-checksum.json => third_party/rust/rand-0.6.5/.cargo-checksum.json rename : third_party/rust/rand/CHANGELOG.md => third_party/rust/rand-0.6.5/CHANGELOG.md rename : third_party/rust/rand/Cargo.toml => third_party/rust/rand-0.6.5/Cargo.toml rename : third_party/rust/rand/README.md => third_party/rust/rand-0.6.5/README.md rename : third_party/rust/rand/benches/distributions.rs => third_party/rust/rand-0.6.5/benches/distributions.rs rename : third_party/rust/rand/benches/generators.rs => third_party/rust/rand-0.6.5/benches/generators.rs rename : third_party/rust/rand/benches/misc.rs => third_party/rust/rand-0.6.5/benches/misc.rs rename : third_party/rust/rand/benches/seq.rs => third_party/rust/rand-0.6.5/benches/seq.rs rename : third_party/rust/rand/build.rs => third_party/rust/rand-0.6.5/build.rs rename : third_party/rust/rand/examples/monte-carlo.rs => third_party/rust/rand-0.6.5/examples/monte-carlo.rs rename : third_party/rust/rand/examples/monty-hall.rs => third_party/rust/rand-0.6.5/examples/monty-hall.rs rename : third_party/rust/rand/src/deprecated.rs => third_party/rust/rand-0.6.5/src/deprecated.rs rename : third_party/rust/rand/src/distributions/bernoulli.rs => third_party/rust/rand-0.6.5/src/distributions/bernoulli.rs rename : third_party/rust/rand/src/distributions/binomial.rs => third_party/rust/rand-0.6.5/src/distributions/binomial.rs rename : third_party/rust/rand/src/distributions/cauchy.rs => third_party/rust/rand-0.6.5/src/distributions/cauchy.rs rename : third_party/rust/rand/src/distributions/dirichlet.rs => third_party/rust/rand-0.6.5/src/distributions/dirichlet.rs rename : third_party/rust/rand/src/distributions/exponential.rs => third_party/rust/rand-0.6.5/src/distributions/exponential.rs rename : third_party/rust/rand/src/distributions/float.rs => third_party/rust/rand-0.6.5/src/distributions/float.rs rename : third_party/rust/rand/src/distributions/gamma.rs => third_party/rust/rand-0.6.5/src/distributions/gamma.rs rename : third_party/rust/rand/src/distributions/integer.rs => third_party/rust/rand-0.6.5/src/distributions/integer.rs rename : third_party/rust/rand/src/distributions/mod.rs => third_party/rust/rand-0.6.5/src/distributions/mod.rs rename : third_party/rust/rand/src/distributions/normal.rs => third_party/rust/rand-0.6.5/src/distributions/normal.rs rename : third_party/rust/rand/src/distributions/other.rs => third_party/rust/rand-0.6.5/src/distributions/other.rs rename : third_party/rust/rand/src/distributions/pareto.rs => third_party/rust/rand-0.6.5/src/distributions/pareto.rs rename : third_party/rust/rand/src/distributions/poisson.rs => third_party/rust/rand-0.6.5/src/distributions/poisson.rs rename : third_party/rust/rand/src/distributions/triangular.rs => third_party/rust/rand-0.6.5/src/distributions/triangular.rs rename : third_party/rust/rand/src/distributions/uniform.rs => third_party/rust/rand-0.6.5/src/distributions/uniform.rs rename : third_party/rust/rand/src/distributions/unit_circle.rs => third_party/rust/rand-0.6.5/src/distributions/unit_circle.rs rename : third_party/rust/rand/src/distributions/unit_sphere.rs => third_party/rust/rand-0.6.5/src/distributions/unit_sphere.rs rename : third_party/rust/rand/src/distributions/utils.rs => third_party/rust/rand-0.6.5/src/distributions/utils.rs rename : third_party/rust/rand/src/distributions/weibull.rs => third_party/rust/rand-0.6.5/src/distributions/weibull.rs rename : third_party/rust/rand/src/distributions/weighted.rs => third_party/rust/rand-0.6.5/src/distributions/weighted.rs rename : third_party/rust/rand/src/lib.rs => third_party/rust/rand-0.6.5/src/lib.rs rename : third_party/rust/rand/src/prelude.rs => third_party/rust/rand-0.6.5/src/prelude.rs rename : third_party/rust/rand/src/prng/mod.rs => third_party/rust/rand-0.6.5/src/prng/mod.rs rename : third_party/rust/rand/src/rngs/adapter/mod.rs => third_party/rust/rand-0.6.5/src/rngs/adapter/mod.rs rename : third_party/rust/rand/src/rngs/adapter/read.rs => third_party/rust/rand-0.6.5/src/rngs/adapter/read.rs rename : third_party/rust/rand/src/rngs/adapter/reseeding.rs => third_party/rust/rand-0.6.5/src/rngs/adapter/reseeding.rs rename : third_party/rust/rand/src/rngs/entropy.rs => third_party/rust/rand-0.6.5/src/rngs/entropy.rs rename : third_party/rust/rand/src/rngs/mock.rs => third_party/rust/rand-0.6.5/src/rngs/mock.rs rename : third_party/rust/rand/src/rngs/mod.rs => third_party/rust/rand-0.6.5/src/rngs/mod.rs rename : third_party/rust/rand/src/rngs/small.rs => third_party/rust/rand-0.6.5/src/rngs/small.rs rename : third_party/rust/rand/src/rngs/std.rs => third_party/rust/rand-0.6.5/src/rngs/std.rs rename : third_party/rust/rand/src/rngs/thread.rs => third_party/rust/rand-0.6.5/src/rngs/thread.rs rename : third_party/rust/rand/src/seq/index.rs => third_party/rust/rand-0.6.5/src/seq/index.rs rename : third_party/rust/rand/src/seq/mod.rs => third_party/rust/rand-0.6.5/src/seq/mod.rs rename : third_party/rust/rand/tests/uniformity.rs => third_party/rust/rand-0.6.5/tests/uniformity.rs rename : third_party/rust/rand/src/distributions/weighted.rs => third_party/rust/rand/src/distributions/weighted/mod.rs rename : third_party/rust/rand_chacha/.cargo-checksum.json => third_party/rust/rand_chacha-0.1.1/.cargo-checksum.json rename : third_party/rust/rand_chacha/CHANGELOG.md => third_party/rust/rand_chacha-0.1.1/CHANGELOG.md rename : third_party/rust/rand_chacha/Cargo.toml => third_party/rust/rand_chacha-0.1.1/Cargo.toml rename : third_party/rust/rand_chacha/README.md => third_party/rust/rand_chacha-0.1.1/README.md rename : third_party/rust/rand_chacha/build.rs => third_party/rust/rand_chacha-0.1.1/build.rs rename : third_party/rust/rand_chacha/src/chacha.rs => third_party/rust/rand_chacha-0.1.1/src/chacha.rs rename : third_party/rust/rand_chacha/src/lib.rs => third_party/rust/rand_chacha-0.1.1/src/lib.rs rename : third_party/rust/rand_core/.cargo-checksum.json => third_party/rust/rand_core-0.4.0/.cargo-checksum.json rename : third_party/rust/rand_core/CHANGELOG.md => third_party/rust/rand_core-0.4.0/CHANGELOG.md rename : third_party/rust/rand_core/Cargo.toml => third_party/rust/rand_core-0.4.0/Cargo.toml rename : third_party/rust/rand_core/README.md => third_party/rust/rand_core-0.4.0/README.md rename : third_party/rust/rand_core/src/block.rs => third_party/rust/rand_core-0.4.0/src/block.rs rename : third_party/rust/rand_core/src/error.rs => third_party/rust/rand_core-0.4.0/src/error.rs rename : third_party/rust/rand_core/src/impls.rs => third_party/rust/rand_core-0.4.0/src/impls.rs rename : third_party/rust/rand_core/src/lib.rs => third_party/rust/rand_core-0.4.0/src/lib.rs rename : third_party/rust/rand_hc/.cargo-checksum.json => third_party/rust/rand_hc-0.1.0/.cargo-checksum.json rename : third_party/rust/rand_hc/CHANGELOG.md => third_party/rust/rand_hc-0.1.0/CHANGELOG.md rename : third_party/rust/rand_hc/Cargo.toml => third_party/rust/rand_hc-0.1.0/Cargo.toml rename : third_party/rust/rand_hc/README.md => third_party/rust/rand_hc-0.1.0/README.md rename : third_party/rust/rand_hc/src/hc128.rs => third_party/rust/rand_hc-0.1.0/src/hc128.rs rename : third_party/rust/rand_hc/src/lib.rs => third_party/rust/rand_hc-0.1.0/src/lib.rs rename : third_party/rust/rand_pcg/.cargo-checksum.json => third_party/rust/rand_pcg-0.1.2/.cargo-checksum.json rename : third_party/rust/rand_pcg/CHANGELOG.md => third_party/rust/rand_pcg-0.1.2/CHANGELOG.md rename : third_party/rust/rand_pcg/Cargo.toml => third_party/rust/rand_pcg-0.1.2/Cargo.toml rename : third_party/rust/rand_pcg/README.md => third_party/rust/rand_pcg-0.1.2/README.md rename : third_party/rust/rand_chacha/build.rs => third_party/rust/rand_pcg-0.1.2/build.rs rename : third_party/rust/rand_pcg/src/lib.rs => third_party/rust/rand_pcg-0.1.2/src/lib.rs rename : third_party/rust/rand_pcg/src/pcg128.rs => third_party/rust/rand_pcg-0.1.2/src/pcg128.rs rename : third_party/rust/rand_pcg/src/pcg64.rs => third_party/rust/rand_pcg-0.1.2/src/pcg64.rs rename : third_party/rust/rand_pcg/tests/lcg64xsh32.rs => third_party/rust/rand_pcg-0.1.2/tests/lcg64xsh32.rs rename : third_party/rust/rand_pcg/tests/mcg128xsl64.rs => third_party/rust/rand_pcg-0.1.2/tests/mcg128xsl64.rs extra : moz-landing-system : lando |
||
---|---|---|
.. | ||
benches | ||
examples | ||
src | ||
tests | ||
.cargo-checksum.json | ||
CHANGELOG.md | ||
COPYRIGHT | ||
Cargo.toml | ||
LICENSE-APACHE | ||
LICENSE-MIT | ||
README.md | ||
build.rs |
README.md
Rand
A Rust library for random number generation.
Rand provides utilities to generate random numbers, to convert them to useful types and distributions, and some randomness-related algorithms.
The core random number generation traits of Rand live in the rand_core crate but are also exposed here; RNG
implementations should prefer to use rand_core
while most other users should
depend on rand
.
Documentation:
Usage
Add this to your Cargo.toml
:
[dependencies]
rand = "0.6"
To get started using Rand, see The Book.
Versions
The Rand lib is not yet stable, however we are careful to limit breaking changes and warn via deprecation wherever possible. Patch versions never introduce breaking changes. The following minor versions are supported:
- Version 0.6 was released in November 2018, redesigning the
seq
module, moving most PRNGs to external crates, and many small changes. - Version 0.5 was released in May 2018, as a major reorganisation
(introducing
RngCore
andrand_core
, and deprecatingRand
and the previous distribution traits). - Version 0.4 was released in December 2017, but contained almost no breaking changes from the 0.3 series.
A detailed changelog is available.
When upgrading to the next minor series (especially 0.4 → 0.5), we recommend reading the Upgrade Guide.
Rust version requirements
Since version 0.5, Rand requires Rustc version 1.22 or greater. Rand 0.4 and 0.3 (since approx. June 2017) require Rustc version 1.15 or greater. Subsets of the Rand code may work with older Rust versions, but this is not supported.
Travis CI always has a build with a pinned version of Rustc matching the oldest supported Rust release. The current policy is that this can be updated in any Rand release if required, but the change must be noted in the changelog.
To avoid bumping the required version unnecessarily, we use a build.rs
script
to auto-detect the compiler version and enable certain features or change code
paths automatically. Since this makes it easy to unintentionally make use of
features requiring a more recent Rust version, we recommend testing with a
pinned version of Rustc if you require compatibility with a specific version.
Crate Features
Rand is built with the std
and rand_os
features enabled by default:
std
enables functionality dependent on thestd
lib and impliesalloc
andrand_os
rand_os
enables therand_os
crate,rngs::OsRng
and enables its usage; the continued existance of this feature is not guaranteed so users are encouraged to specifystd
instead
The following optional features are available:
alloc
can be used instead ofstd
to provideVec
andBox
.log
enables some logging via thelog
crate.nightly
enables all unstable features (simd_support
).serde1
enables serialization for some types, via Serde version 1.simd_support
enables uniform sampling of SIMD types (integers and floats).stdweb
enables support forOsRng
onwasm32-unknown-unknown
viastdweb
combined withcargo-web
.wasm-bindgen
enables support forOsRng
onwasm32-unknown-unknown
viawasm-bindgen
no_std
mode is activated by setting default-features = false
; this removes
functionality depending on std
:
thread_rng()
, andrandom()
are not available, as they require thread-local storage and an entropy source.OsRng
andEntropyRng
are unavailable.JitterRng
code is still present, but a nanosecond timer must be provided viaJitterRng::new_with_timer
- 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
andlog
functions are not provided incore
. - Large parts of the
seq
-uence module are unavailable, unless thealloc
feature is used (several APIs and many implementations requireVec
).
License
Rand is distributed under the terms of both the MIT license and the Apache License (Version 2.0).
See LICENSE-APACHE and LICENSE-MIT, and COPYRIGHT for details.