Skip to content

Commit 939c8a3

Browse files
authored
Merge pull request #639 from dhardy/doc
Doc changes for 0.6 and the new book
2 parents be9c864 + ae895a9 commit 939c8a3

File tree

9 files changed

+119
-1078
lines changed

9 files changed

+119
-1078
lines changed

CHANGELOG.md

Lines changed: 57 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,70 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
A [separate changelog is kept for rand_core](rand_core/CHANGELOG.md).
88

9-
You may also find the [Update Guide](UPDATING.md) useful.
10-
11-
12-
## [0.6.0] - Unreleased
13-
14-
### Crate features and organisation
15-
- The ISAAC and Xorshift RNGs have been moved to their own crates: `rand_isaac`
16-
and `rand_xorshift`. (#551, #557)
9+
You may also find the [Upgrade Guide](https://rust-random.github.io/book/update.html) useful.
10+
11+
12+
## [0.6.0] - 2018-11-14
13+
14+
### Project organisation
15+
- Rand has moved from [rust-lang-nursery](https://github.com/rust-lang-nursery/rand)
16+
to [rust-random](https://github.com/rust-random/rand)! (#578)
17+
- Created [The Rust Random Book](https://rust-random.github.io/book/)
18+
([source](https://github.com/rust-random/book))
19+
- Update copyright and licence notices (#591, #611)
20+
- Migrate policy documentation from the wiki (#544)
21+
22+
### Platforms
23+
- Add fork protection on Unix (#466)
24+
- Added support for wasm-bindgen. (#541, #559, #562, #600)
25+
- Enable `OsRng` for powerpc64, sparc and sparc64 (#609)
26+
- Use `syscall` from `libc` on Linux instead of redefining it (#629)
27+
28+
### RNGs
29+
- Switch `SmallRng` to use PCG (#623)
30+
- Implement `Pcg32` and `Pcg64Mcg` generators (#632)
31+
- Move ISAAC RNGs to a dedicated crate (#551)
32+
- Move Xorshift RNG to its own crate (#557)
33+
- Move ChaCha and HC128 RNGs to dedicated crates (#607, #636)
34+
- Remove usage of `Rc` from `ThreadRng` (#615)
35+
36+
### Sampling and distributions
37+
- Implement `Rng.gen_ratio()` and `Bernoulli::new_ratio()` (#491)
38+
- Make `Uniform` strictly respect `f32` / `f64` high/low bounds (#477)
39+
- Allow `gen_range` and `Uniform` to work on non-`Copy` types (#506)
1740
- `Uniform` supports inclusive ranges: `Uniform::from(a..=b)`. This is
1841
automatically enabled for Rust >= 1.27. (#566)
19-
- Support for `i128` and `u128` is automatically enabled for Rust >= 1.26. This
20-
renders the `i128_support` feature obsolete. It still exists for backwards
21-
compatibility but does not have any effect. This breaks programs using Rand
22-
with `i128_support` on nightlies older than Rust 1.26. (#571)
42+
- Implement `TrustedLen` and `FusedIterator` for `DistIter` (#620)
2343

24-
### New distributions
44+
#### New distributions
45+
- Add the `Dirichlet` distribution (#485)
2546
- Added sampling from the unit sphere and circle. (#567)
47+
- Implement the triangular distribution (#575)
48+
- Implement the Weibull distribution (#576)
49+
- Implement the Beta distribution (#574)
2650

27-
### Sequences module
51+
#### Optimisations
52+
53+
- Optimise `Bernoulli::new` (#500)
54+
- Optimise `char` sampling (#519)
55+
- Optimise sampling of `std::time::Duration` (#583)
56+
57+
### Sequences
58+
- Redesign the `seq` module (#483, #515)
59+
- Add `WeightedIndex` and `choose_weighted` (#518, #547)
2860
- Optimised and changed return type of the `sample_indices` function. (#479)
29-
- Added weighted sampling. (#518)
61+
- Use `Iterator::size_hint()` to speed up `IteratorRandom::choose` (#593)
3062

31-
### Platform support
32-
- Added support for wasm-bindgen. (#541)
33-
- Added basic SIMD support. (#523)
63+
### SIMD
64+
- Support for generating SIMD types (#523, #542, #561, #630)
65+
66+
### Other
67+
- Revise CI scripts (#632, #635)
68+
- Remove functionality already deprecated in 0.5 (#499)
69+
- Support for `i128` and `u128` is automatically enabled for Rust >= 1.26. This
70+
renders the `i128_support` feature obsolete. It still exists for backwards
71+
compatibility but does not have any effect. This breaks programs using Rand
72+
with `i128_support` on nightlies older than Rust 1.26. (#571)
3473

3574

3675
## [0.5.5] - 2018-08-07

CONTRIBUTING.md

Lines changed: 0 additions & 93 deletions
This file was deleted.

README.md

Lines changed: 31 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@ Rand provides utilities to generate random numbers, to convert them to useful
1313
types and distributions, and some randomness-related algorithms.
1414

1515
The core random number generation traits of Rand live in the [rand_core](
16-
https://crates.io/crates/rand_core) crate; this crate is most useful when
17-
implementing RNGs.
16+
https://crates.io/crates/rand_core) crate but are also exposed here; RNG
17+
implementations should prefer to use `rand_core` while most other users should
18+
depend on `rand`.
1819

1920
Documentation:
20-
- [API reference for latest release](https://docs.rs/rand/0.5)
21-
- [API reference for master branch](https://rust-random.github.io/rand/rand/index.html)
22-
- [Additional documentation (subdir)](doc/README.md)
21+
- [The Rust Rand Book](https://rust-random.github.io/book/)
22+
- [API reference for the latest release](https://docs.rs/rand/)
23+
- [API reference for the master branch](https://rust-random.github.io/rand/)
2324

2425

2526
## Usage
@@ -28,78 +29,34 @@ Add this to your `Cargo.toml`:
2829

2930
```toml
3031
[dependencies]
31-
rand = "0.5"
32+
rand = "0.6"
3233
```
3334

34-
and this to your crate root:
35-
36-
```rust
37-
extern crate rand;
38-
39-
use rand::prelude::*;
40-
41-
fn main() {
42-
// basic usage with random():
43-
let x: u8 = random();
44-
println!("{}", x);
45-
46-
let y = random::<f64>();
47-
println!("{}", y);
48-
49-
if random() { // generates a boolean
50-
println!("Heads!");
51-
}
52-
53-
// normal usage needs both an RNG and a function to generate the appropriate
54-
// type, range, distribution, etc.
55-
let mut rng = thread_rng();
56-
if rng.gen() { // random bool
57-
let x: f64 = rng.gen(); // random number in range [0, 1)
58-
println!("x is: {}", x);
59-
let ch = rng.gen::<char>(); // Sometimes you need type annotation
60-
println!("char is: {}", ch);
61-
println!("Number from 0 to 9: {}", rng.gen_range(0, 10));
62-
}
63-
}
64-
```
65-
66-
## Functionality
67-
68-
The Rand crate provides:
69-
70-
- A convenient to use default RNG, `thread_rng`: an automatically seeded,
71-
crypto-grade generator stored in thread-local memory.
72-
- Pseudo-random number generators: `StdRng`, `SmallRng`, `prng` module.
73-
- Functionality for seeding PRNGs: the `FromEntropy` trait, and as sources of
74-
external randomness `EntropyRng`, `OsRng` and `JitterRng`.
75-
- Most content from [`rand_core`](https://crates.io/crates/rand_core)
76-
(re-exported): base random number generator traits and error-reporting types.
77-
- 'Distributions' producing many different types of random values:
78-
- A `Standard` distribution for integers, floats, and derived types including
79-
tuples, arrays and `Option`
80-
- Unbiased sampling from specified `Uniform` ranges.
81-
- Sampling from exponential/normal/gamma distributions.
82-
- Sampling from binomial/poisson distributions.
83-
- `gen_bool` aka Bernoulli distribution.
84-
- `seq`-uence related functionality:
85-
- Sampling a subset of elements.
86-
- Randomly shuffling a list.
35+
To get started using Rand, see [The Book](https://rust-random.github.io/book/).
8736

8837

8938
## Versions
9039

91-
Version 0.5 is the latest version and contains many breaking changes.
92-
See [the Upgrade Guide](UPDATING.md) for guidance on updating from previous
93-
versions.
40+
The Rand lib is not yet stable, however we are careful to limit breaking changes
41+
and warn via deprecation wherever possible. Patch versions never introduce
42+
breaking changes. The following minor versions are supported:
43+
44+
- Version 0.6 was released in November 2018, redesigning the `seq` module,
45+
moving most PRNGs to external crates, and many small changes.
46+
- Version 0.5 was released in May 2018, as a major reorganisation
47+
(introducing `RngCore` and `rand_core`, and deprecating `Rand` and the
48+
previous distribution traits).
49+
- Version 0.4 was released in December 2017, but contained almost no breaking
50+
changes from the 0.3 series.
9451

95-
Version 0.4 was released in December 2017. It contains almost no breaking
96-
changes since the 0.3 series.
52+
A detailed [changelog](CHANGELOG.md) is available.
9753

98-
For more details, see the [changelog](CHANGELOG.md).
54+
When upgrading to the next minor series (especially 0.4 → 0.5), we recommend
55+
reading the [Upgrade Guide](https://rust-random.github.io/book/update.html).
9956

10057
### Rust version requirements
10158

102-
The 0.5 release of Rand requires **Rustc version 1.22 or greater**.
59+
Since version 0.5, Rand requires **Rustc version 1.22 or greater**.
10360
Rand 0.4 and 0.3 (since approx. June 2017) require Rustc version 1.15 or
10461
greater. Subsets of the Rand code may work with older Rust versions, but this
10562
is not supported.
@@ -108,6 +65,11 @@ Travis CI always has a build with a pinned version of Rustc matching the oldest
10865
supported Rust release. The current policy is that this can be updated in any
10966
Rand release if required, but the change must be noted in the changelog.
11067

68+
To avoid bumping the required version unnecessarily, we use a `build.rs` script
69+
to auto-detect the compiler version and enable certain features or change code
70+
paths automatically. Since this makes it easy to unintentionally make use of
71+
features requiring a more recent Rust version, we recommend testing with a
72+
pinned version of Rustc if you require compatibility with a specific version.
11173

11274
## Crate Features
11375

@@ -137,9 +99,10 @@ functionality depending on `std`:
13799
- Since no external entropy is available, it is not possible to create
138100
generators with fresh seeds using the `FromEntropy` trait (user must provide
139101
a seed).
140-
- Exponential, normal and gamma type distributions are unavailable since `exp`
102+
- Several non-linear distributions distributions are unavailable since `exp`
141103
and `log` functions are not provided in `core`.
142-
- The `seq`-uence module is unavailable, as it requires `Vec`.
104+
- Large parts of the `seq`-uence module are unavailable, unless the `alloc`
105+
feature is used (several APIs and many implementations require `Vec`).
143106

144107

145108
# License

0 commit comments

Comments
 (0)