diff options
| author | Felix S. Klock II <pnkfelix@pnkfx.org> | 2015-02-20 00:10:08 +0100 |
|---|---|---|
| committer | Felix S. Klock II <pnkfelix@pnkfx.org> | 2015-03-03 12:10:57 +0100 |
| commit | 6189e99c8605578aae841be6fba9e27bfbad97fc (patch) | |
| tree | 3c4019f4987c0825d751474029637a9b670f9dbf /src/libstd | |
| parent | 7c8edabac8030889f4a885b944c86190772953fd (diff) | |
| download | rust-6189e99c8605578aae841be6fba9e27bfbad97fc.tar.gz rust-6189e99c8605578aae841be6fba9e27bfbad97fc.zip | |
Accommodate arith-overflow in `rand` and `std::rand`.
Regarding the `rand` changes: It is unfortunate that Wrapping(T) does not support the `+=` operator. We may want to try to fix that before 1.0 to make porting code like this palatable. Regarding `std::rand`, just arith-overflow in first example from `std::rand::random()` doc.
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/rand/mod.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/libstd/rand/mod.rs b/src/libstd/rand/mod.rs index 5c891441198..ac7622fc7f7 100644 --- a/src/libstd/rand/mod.rs +++ b/src/libstd/rand/mod.rs @@ -386,8 +386,8 @@ impl Rng for ThreadRng { /// ``` /// use std::rand; /// -/// let x = rand::random(); -/// println!("{}", 2u8 * x); +/// let x: u8 = rand::random(); +/// println!("{}", 2 * x as u16); /// /// let y = rand::random::<f64>(); /// println!("{}", y); |
