mirror of
https://github.com/encounter/rust-sdl2.git
synced 2026-07-10 21:18:41 -07:00
Update Rand to 0.6.* from 0.5.*
This commit is contained in:
committed by
Cobrand
parent
8f27656a6a
commit
cac7a197be
+1
-1
@@ -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
@@ -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())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user