From cac7a197beb4b7dd965ff83b3e042597546db510 Mon Sep 17 00:00:00 2001 From: Drew Pirrone-Brusse Date: Thu, 20 Dec 2018 15:31:24 -0500 Subject: [PATCH] Update Rand to 0.6.* from 0.5.* --- Cargo.toml | 2 +- src/sdl2/pixels.rs | 18 +++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 867b05ff..40da1875 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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] diff --git a/src/sdl2/pixels.rs b/src/sdl2/pixels.rs index c526f304..8ea0af18 100644 --- a/src/sdl2/pixels.rs +++ b/src/sdl2/pixels.rs @@ -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(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 for Standard { + fn sample(&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()) + } } }