Update Rand to 0.6.* from 0.5.*

This commit is contained in:
Drew Pirrone-Brusse
2018-12-21 13:37:35 +01:00
committed by Cobrand
parent 8f27656a6a
commit cac7a197be
2 changed files with 12 additions and 8 deletions
+1 -1
View File
@@ -18,7 +18,7 @@ path = "src/sdl2/lib.rs"
[dependencies]
bitflags = "^1"
libc = "^0.2"
rand = "^0.5"
rand = "^0.6"
lazy_static = "^1"
[dependencies.num]
+11 -7
View File
@@ -1,10 +1,11 @@
extern crate rand;
use self::rand::Rng;
use self::rand::distributions::{Distribution, Standard};
use num::FromPrimitive;
use sys;
use libc::uint32_t;
use num::FromPrimitive;
use std::mem::transmute;
use sys;
use get_error;
@@ -170,10 +171,13 @@ impl From<(u8, u8, u8, u8)> for Color {
}
}
impl rand::Rand for Color {
fn rand<R: rand::Rng>(rng: &mut R) -> Color {
if rng.gen() { Color::RGBA(rng.gen(), rng.gen(), rng.gen(), rng.gen()) }
else { Color::RGB(rng.gen(), rng.gen(), rng.gen()) }
impl Distribution<Color> for Standard {
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Color {
if rng.gen() {
Color::RGBA(rng.gen(), rng.gen(), rng.gen(), rng.gen())
} else {
Color::RGB(rng.gen(), rng.gen(), rng.gen())
}
}
}