Skip to content

Commit

Permalink
Update code to work with rand 0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
torkleyy committed Jan 4, 2019
1 parent ce5d624 commit 9470e4e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
5 changes: 2 additions & 3 deletions benches/world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,15 @@ fn delete_later(b: &mut Bencher) {
}

fn create_after_delete(b: &mut Bencher) {
use rand::seq::sample_indices;
use rand::thread_rng;
use rand::prelude::*;

let mut rng = thread_rng();
b.iter_with_setup(
|| {
let mut w = World::new();
let eids: Vec<_> = (0..1000).map(|_| w.create_entity().build()).collect();

sample_indices(&mut rng, 1000, 100)
(0..1000).choose_multiple(&mut rng, 100)
.into_iter()
.map(|i| eids[i])
.for_each(|e| {
Expand Down
7 changes: 4 additions & 3 deletions examples/cluster_bomb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ extern crate rand;
extern crate rayon;
extern crate specs;

use rand::Rng;
use rand::distributions::{Distribution, Range};
use rand::prelude::*;

use rayon::iter::ParallelIterator;

Expand Down Expand Up @@ -56,7 +55,9 @@ impl<'a> System<'a> for ClusterBombSystem {
);

fn run(&mut self, (entities, mut bombs, positions, updater): Self::SystemData) {
let durability_range = Range::new(10, 20);
use rand::distributions::{Distribution, Uniform};

let durability_range = Uniform::new(10, 20);
// Join components in potentially parallel way using rayon.
(&entities, &mut bombs, &positions)
.par_join()
Expand Down

0 comments on commit 9470e4e

Please sign in to comment.