Skip to content

Commit 6f97936

Browse files
committed
use sliceRandom instead of deprecated choose method
remove yarn lock
1 parent d578cfc commit 6f97936

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

crates/binjs_generic/src/pick.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ impl Pick for TypeSpec {
7575
json::from(string)
7676
}
7777
TypeSpec::Number => {
78-
json::from(rng.next_u64())
78+
json::from(rng.gen::<f64>())
7979
}
8080
TypeSpec::Void =>
8181
JSON::Null,

crates/binjs_io/src/bytes/compress.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use rand::Rng;
77
use rand::distributions::Distribution;
88
use rand::distributions::Standard;
99
use rand::thread_rng;
10+
use rand::seq::SliceRandom;
1011

1112
use std;
1213
use std::collections::HashSet;
@@ -37,9 +38,13 @@ pub enum Compression {
3738
impl Distribution<Compression> for Standard {
3839
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Compression {
3940
use self::Compression::*;
40-
rng.choose(&[Identity, Gzip, /* Deflate is apprently broken https://github.com/alexcrichton/flate2-rs/issues/151 , */ Brotli /*, Lzw doesn't work yet */])
41+
let choices = [Identity, Gzip, /* Deflate is apprently broken https://github.com/alexcrichton/flate2-rs/issues/151 , */ Brotli /*, Lzw doesn't work yet */];
42+
choices.choose(rng)
4143
.unwrap()
4244
.clone()
45+
// rng.choose(&[Identity, Gzip, /* Deflate is apprently broken https://github.com/alexcrichton/flate2-rs/issues/151 , */ Brotli /*, Lzw doesn't work yet */])
46+
// .unwrap()
47+
// .clone()
4348
}
4449
}
4550

crates/binjs_io/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ use std::rc::Rc;
2828

2929
use rand::Rng;
3030
use rand::distributions::{ Distribution, Standard };
31+
use rand::seq::SliceRandom;
3132

3233
pub use bytes::compress::Compression;
3334

@@ -234,7 +235,7 @@ impl Distribution<Format> for Standard {
234235
}),
235236
Rc::new(|_| Format::XML),
236237
];
237-
let pick : Rc<Fn(&'a mut R) -> Format> = rng.choose(&generators)
238+
let pick : Rc<Fn(&'a mut R) -> Format> = generators.choose(rng)
238239
.map(Rc::clone)
239240
.unwrap(); // Never empty
240241
pick(rng)

0 commit comments

Comments
 (0)