From 4d5ba7918be1a471a61b737e067fa7123ea14fd0 Mon Sep 17 00:00:00 2001 From: Christopher Durham Date: Sun, 17 Jan 2021 16:43:03 -0500 Subject: [PATCH] Update rand requirement from 0.7 to 0.8 (#1114) * Update rand requirement from 0.7 to 0.8 * Update examples' usage of Rng::gen_range --- Cargo.toml | 2 +- crates/bevy_asset/Cargo.toml | 2 +- crates/bevy_ecs/Cargo.toml | 2 +- examples/2d/contributors.rs | 12 ++++++------ examples/3d/spawner.rs | 10 +++++----- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 17edc06eb1..4ef33fd568 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -81,7 +81,7 @@ bevy_internal = {path = "crates/bevy_internal", version = "0.4.0", default-featu [dev-dependencies] anyhow = "1.0" -rand = "0.7.3" +rand = "0.8.0" ron = "0.6.2" serde = {version = "1", features = ["derive"]} diff --git a/crates/bevy_asset/Cargo.toml b/crates/bevy_asset/Cargo.toml index 1b8a01e6a3..2171710723 100644 --- a/crates/bevy_asset/Cargo.toml +++ b/crates/bevy_asset/Cargo.toml @@ -34,7 +34,7 @@ thiserror = "1.0" downcast-rs = "1.2.0" notify = { version = "5.0.0-pre.2", optional = true } parking_lot = "0.11.0" -rand = "0.7.3" +rand = "0.8.0" [target.'cfg(target_arch = "wasm32")'.dependencies] wasm-bindgen = { version = "0.2" } diff --git a/crates/bevy_ecs/Cargo.toml b/crates/bevy_ecs/Cargo.toml index cbeade0b59..a29b480b41 100644 --- a/crates/bevy_ecs/Cargo.toml +++ b/crates/bevy_ecs/Cargo.toml @@ -21,7 +21,7 @@ bevy_tasks = { path = "../bevy_tasks", version = "0.4.0" } bevy_utils = { path = "../bevy_utils", version = "0.4.0" } bevy_ecs_macros = { path = "macros", version = "0.4.0" } fxhash = "0.2" -rand = "0.7.3" +rand = "0.8.0" serde = "1.0" thiserror = "1.0" fixedbitset = "0.3.1" diff --git a/examples/2d/contributors.rs b/examples/2d/contributors.rs index a38ab5dca2..d110c7f542 100644 --- a/examples/2d/contributors.rs +++ b/examples/2d/contributors.rs @@ -66,8 +66,8 @@ fn setup( let mut rnd = rand::thread_rng(); for name in contribs { - let pos = (rnd.gen_range(-400.0, 400.0), rnd.gen_range(0.0, 400.0)); - let dir = rnd.gen_range(-1.0, 1.0); + let pos = (rnd.gen_range(-400.0..400.0), rnd.gen_range(0.0..400.0)); + let dir = rnd.gen_range(-1.0..1.0); let velocity = Vec3::new(dir * 500.0, 0.0, 0.0); let col = gen_color(&mut rnd); @@ -254,7 +254,7 @@ fn collision_system( if bottom < ground { t.translation.y = ground + SPRITE_SIZE / 2.0; // apply an impulse upwards - v.translation.y = rnd.gen_range(700.0, 1000.0); + v.translation.y = rnd.gen_range(700.0..1000.0); } if top > ceiling { t.translation.y = ceiling - SPRITE_SIZE / 2.0; @@ -312,9 +312,9 @@ fn contributors() -> Contributors { /// Because there is no `Mul for Color` instead `[f32; 3]` is /// used. fn gen_color(rng: &mut impl Rng) -> [f32; 3] { - let r = rng.gen_range(0.2, 1.0); - let g = rng.gen_range(0.2, 1.0); - let b = rng.gen_range(0.2, 1.0); + let r = rng.gen_range(0.2..1.0); + let g = rng.gen_range(0.2..1.0); + let b = rng.gen_range(0.2..1.0); let v = Vec3::new(r, g, b); v.normalize().into() } diff --git a/examples/3d/spawner.rs b/examples/3d/spawner.rs index 1dc2cee20d..09a88c7d55 100644 --- a/examples/3d/spawner.rs +++ b/examples/3d/spawner.rs @@ -56,15 +56,15 @@ fn setup( mesh: cube_handle.clone(), material: materials.add(StandardMaterial { albedo: Color::rgb( - rng.gen_range(0.0, 1.0), - rng.gen_range(0.0, 1.0), - rng.gen_range(0.0, 1.0), + rng.gen_range(0.0..1.0), + rng.gen_range(0.0..1.0), + rng.gen_range(0.0..1.0), ), ..Default::default() }), transform: Transform::from_xyz( - rng.gen_range(-50.0, 50.0), - rng.gen_range(-50.0, 50.0), + rng.gen_range(-50.0..50.0), + rng.gen_range(-50.0..50.0), 0.0, ), ..Default::default()