From 6189e99c8605578aae841be6fba9e27bfbad97fc Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Fri, 20 Feb 2015 00:10:08 +0100 Subject: 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. --- src/libstd/rand/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/libstd') 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::(); /// println!("{}", y); -- cgit 1.4.1-3-g733a5