diff --git a/.travis.yml b/.travis.yml index 8969ac0..d01a635 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: rust rust: - - 1.20.0 + - 1.22.0 - stable - beta - nightly diff --git a/Cargo.toml b/Cargo.toml index f737cb2..aaf09e5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,4 +24,4 @@ name = "quickcheck" [dependencies] env_logger = { version = "0.5", default-features = false, optional = true } log = { version = "0.4", optional = true } -rand = "0.4" +rand = "0.5" diff --git a/benches/tuples.rs b/benches/tuples.rs index eb20c34..74baec5 100644 --- a/benches/tuples.rs +++ b/benches/tuples.rs @@ -5,7 +5,8 @@ extern crate rand; extern crate test; use quickcheck::{Arbitrary, StdGen}; -use rand::isaac::IsaacRng; +use rand::prng::hc128::Hc128Rng; +use rand::SeedableRng; use test::Bencher; macro_rules! bench_shrink { @@ -14,7 +15,7 @@ macro_rules! bench_shrink { #[bench] fn $fn_name(b: &mut Bencher) { // Use a deterministic generator to benchmark on the same data - let mut gen = StdGen::new(IsaacRng::new_unseeded(), 100); + let mut gen = StdGen::new(Hc128Rng::from_seed([0u8; 32]), 100); let value: $type = Arbitrary::arbitrary(&mut gen); b.iter(|| { diff --git a/src/arbitrary.rs b/src/arbitrary.rs index 6f44b8b..4e090e8 100644 --- a/src/arbitrary.rs +++ b/src/arbitrary.rs @@ -19,14 +19,14 @@ use std::path::PathBuf; use std::sync::Arc; use std::time::Duration; -use rand::Rng; +use rand::{self, Rng, RngCore}; -/// `Gen` wraps a `rand::Rng` with parameters to control the distribution of +/// `Gen` wraps a `rand::RngCore` with parameters to control the distribution of /// random values. /// /// A value with type satisfying the `Gen` trait can be constructed with the /// `gen` function in this crate. -pub trait Gen : Rng { +pub trait Gen : RngCore { fn size(&self) -> usize; } @@ -45,22 +45,25 @@ pub struct StdGen { /// The `size` parameter controls the size of random values generated. /// For example, it specifies the maximum length of a randomly generated vector /// and also will specify the maximum magnitude of a randomly generated number. -impl StdGen { +impl StdGen { pub fn new(rng: R, size: usize) -> StdGen { StdGen { rng: rng, size: size } } } -impl Rng for StdGen { +impl RngCore for StdGen { fn next_u32(&mut self) -> u32 { self.rng.next_u32() } // some RNGs implement these more efficiently than the default, so // we might as well defer to them. fn next_u64(&mut self) -> u64 { self.rng.next_u64() } fn fill_bytes(&mut self, dest: &mut [u8]) { self.rng.fill_bytes(dest) } + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), rand::Error> { + self.rng.try_fill_bytes(dest) + } } -impl Gen for StdGen { +impl Gen for StdGen { fn size(&self) -> usize { self.size } }