diff --git a/Cargo.toml b/Cargo.toml index 72651da..162eb3b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ keywords = ["random", "c-api", "dsl"] [dependencies] rvs-parser = { version = "0.4", path = "parser" } -rand = "0.4" +rand = "0.5.0-pre.0" linked-hash-map = "0.5" [workspace] diff --git a/src/transform/rand.rs b/src/transform/rand.rs index 00217c4..5a92fe5 100644 --- a/src/transform/rand.rs +++ b/src/transform/rand.rs @@ -6,7 +6,7 @@ use rand::{self, Rng, SeedableRng}; pub type CrateRng = rand::XorShiftRng; #[derive(Clone)] -pub struct Seed([u32; 4]); +pub struct Seed([u8; 16]); impl Seed { /// Generates a 128-bit seed from a 32-bit seed @@ -34,7 +34,24 @@ impl Seed { } pub fn from_u32_array(x: [u32; 4]) -> Seed { - Seed(x) + Seed([ + (x[0] >> 0) as u8, + (x[0] >> 8) as u8, + (x[0] >> 16) as u8, + (x[0] >> 24) as u8, + (x[1] >> 0) as u8, + (x[1] >> 8) as u8, + (x[1] >> 16) as u8, + (x[1] >> 24) as u8, + (x[2] >> 0) as u8, + (x[2] >> 8) as u8, + (x[2] >> 16) as u8, + (x[2] >> 24) as u8, + (x[3] >> 0) as u8, + (x[3] >> 8) as u8, + (x[3] >> 16) as u8, + (x[3] >> 24) as u8, + ]) } pub fn to_rng(&self) -> CrateRng { diff --git a/src/types/range.rs b/src/types/range.rs index d255d1f..22638ad 100644 --- a/src/types/range.rs +++ b/src/types/range.rs @@ -2,8 +2,8 @@ use std::fmt; use std::u32; use rand::Rng; use rand::distributions::Range as RandRange; -use rand::distributions::Sample; -use rand::distributions::IndependentSample; +use rand::distributions::{Sample, IndependentSample}; +use rand::distributions::range::RangeInt; use transform::CrateRng; use model::{Expr, ExprData}; @@ -18,7 +18,7 @@ pub struct Range { #[derive(Clone)] pub struct RandRangeInclusive { - range: RandRange, + range: RandRange>, use_range: bool, offset: bool, } diff --git a/src/types/weighted.rs b/src/types/weighted.rs index fcd022a..a42a780 100644 --- a/src/types/weighted.rs +++ b/src/types/weighted.rs @@ -3,6 +3,7 @@ use model::{Expr, ExprData}; use rand::Rng; use rand::distributions::{Range, Sample}; +use rand::distributions::range::RangeInt; use std::fmt; #[derive(Clone)] @@ -10,7 +11,7 @@ pub struct WeightedWithReplacement { data: ExprData, weights: Vec, children: Vec>, - range: Range, + range: Range>, pool: Vec, pool_index: Option, }