Merge pull request #284 from tstenner/rand06

Update rand to 0.6
This commit is contained in:
Sasha Hilton 2019-03-10 18:09:08 +01:00 committed by GitHub
commit 8978559d3a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 853 additions and 474 deletions

View file

@ -1,6 +1,6 @@
language: rust language: rust
rust: rust:
- 1.23.0 - 1.26.0
- stable - stable
- beta - beta
- nightly - nightly

1300
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -41,7 +41,7 @@ hyper = "0.11.2"
log = "0.3.5" log = "0.3.5"
num-bigint = "0.1.35" num-bigint = "0.1.35"
protobuf = "1.1" protobuf = "1.1"
rand = "0.3.13" rand = "0.6"
rpassword = "0.3.0" rpassword = "0.3.0"
rust-crypto = "0.2.36" rust-crypto = "0.2.36"
serde = "0.9.6" serde = "0.9.6"
@ -54,7 +54,7 @@ tokio-signal = "0.1.2"
url = "1.7.0" url = "1.7.0"
[build-dependencies] [build-dependencies]
rand = "0.3.13" rand = "0.6"
vergen = "0.1.0" vergen = "0.1.0"
[replace] [replace]

View file

@ -17,7 +17,7 @@ hyper = "0.11.2"
log = "0.3.5" log = "0.3.5"
num-bigint = "0.1.35" num-bigint = "0.1.35"
protobuf = "2.0.5" protobuf = "2.0.5"
rand = "0.3.13" rand = "0.6"
rust-crypto = "0.2.36" rust-crypto = "0.2.36"
serde = "0.9.6" serde = "0.9.6"
serde_derive = "0.9.6" serde_derive = "0.9.6"

View file

@ -18,7 +18,7 @@ use playback::mixer::Mixer;
use playback::player::Player; use playback::player::Player;
use rand; use rand;
use rand::Rng; use rand::seq::SliceRandom;
use std; use std;
use std::time::{SystemTime, UNIX_EPOCH}; use std::time::{SystemTime, UNIX_EPOCH};
@ -509,7 +509,8 @@ impl SpircTask {
let tracks = self.state.mut_track(); let tracks = self.state.mut_track();
tracks.swap(0, current_index as usize); tracks.swap(0, current_index as usize);
if let Some((_, rest)) = tracks.split_first_mut() { if let Some((_, rest)) = tracks.split_first_mut() {
rand::thread_rng().shuffle(rest); let mut rng = rand::thread_rng();
rest.shuffle(&mut rng);
} }
} }
self.state.set_playing_track_index(0); self.state.set_playing_track_index(0);

View file

@ -23,7 +23,7 @@ num-bigint = "0.1.35"
num-integer = "0.1.32" num-integer = "0.1.32"
num-traits = "0.1.36" num-traits = "0.1.36"
protobuf = "2.0.5" protobuf = "2.0.5"
rand = "0.3.13" rand = "0.6"
rpassword = "0.3.0" rpassword = "0.3.0"
rust-crypto = "0.2.36" rust-crypto = "0.2.36"
serde = "0.9.6" serde = "0.9.6"
@ -36,5 +36,5 @@ url = "1.7.0"
uuid = { version = "0.4", features = ["v4"] } uuid = { version = "0.4", features = ["v4"] }
[build-dependencies] [build-dependencies]
rand = "0.3.13" rand = "0.6"
vergen = "0.1.0" vergen = "0.1.0"

View file

@ -2,6 +2,7 @@ extern crate rand;
extern crate vergen; extern crate vergen;
use rand::Rng; use rand::Rng;
use rand::distributions::Alphanumeric;
use std::env; use std::env;
use std::fs::OpenOptions; use std::fs::OpenOptions;
use std::io::Write; use std::io::Write;
@ -12,7 +13,8 @@ fn main() {
vergen::vergen(vergen::OutputFns::all()).unwrap(); vergen::vergen(vergen::OutputFns::all()).unwrap();
let build_id: String = rand::thread_rng().gen_ascii_chars().take(8).collect(); let mut rng = rand::thread_rng();
let build_id: String = ::std::iter::repeat(()).map(|()| rng.sample(Alphanumeric)).take(8).collect();
let mut version_file = OpenOptions::new() let mut version_file = OpenOptions::new()
.write(true) .write(true)

View file

@ -1,12 +1,12 @@
use num_bigint::BigUint; use num_bigint::BigUint;
use num_integer::Integer; use num_integer::Integer;
use num_traits::{One, Zero}; use num_traits::{One, Zero};
use rand::{Rand, Rng}; use rand::Rng;
use std::mem; use std::mem;
use std::ops::{Mul, Rem, Shr}; use std::ops::{Mul, Rem, Shr};
pub fn rand_vec<G: Rng, R: Rand>(rng: &mut G, size: usize) -> Vec<R> { pub fn rand_vec<G: Rng>(rng: &mut G, size: usize) -> Vec<u8> {
rng.gen_iter().take(size).collect() ::std::iter::repeat(()).map(|()| rng.gen()).take(size).collect()
} }
pub fn powm(base: &BigUint, exp: &BigUint, modulus: &BigUint) -> BigUint { pub fn powm(base: &BigUint, exp: &BigUint, modulus: &BigUint) -> BigUint {