diff --git a/Cargo.toml b/Cargo.toml index 97068ad..b61d572 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,12 +20,12 @@ maintenance = { status = "actively-developed" } # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -pest = "2.4.1" -pest_derive = "2.4.1" -rand = "0.8.5" +pest = "2.8" +pest_derive = "2.8" +rand = "0.10" [dev-dependencies] -rand_core = "0.6.4" +rand_core = "0.10" [features] default = [] diff --git a/src/cards.rs b/src/cards.rs index 033c533..72c7812 100644 --- a/src/cards.rs +++ b/src/cards.rs @@ -85,7 +85,7 @@ impl Deck { suit: Suit::None, }); } - let mut rng = rand::thread_rng(); + let mut rng = rand::rng(); cards.shuffle(&mut rng); cards } @@ -101,7 +101,7 @@ impl Deck { /// Shuffle the remaining cards pub fn shuffle(&mut self) { - let mut rng = rand::thread_rng(); + let mut rng = rand::rng(); self.cards.shuffle(&mut rng); } diff --git a/src/lib.rs b/src/lib.rs index 2f3abbe..7e725a0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -155,7 +155,7 @@ pub use error::*; pub use rollresult::*; use parser::{DiceRollSource, RollParser, Rule}; -use rand::Rng; +use rand::{Rng, RngExt}; const REASON_CHAR: char = ':'; @@ -183,7 +183,7 @@ where T: Rng, { fn roll_single_die(&mut self, sides: u64) -> u64 { - self.rng.gen_range(1..1 + sides) + self.rng.random_range(1..1 + sides) } } @@ -201,7 +201,7 @@ impl Roller { /// Evaluate and roll the dices with default Rng source (`rand::thread_rng()`) pub fn roll(&self) -> Result { - self.roll_with(&mut rand::thread_rng()) + self.roll_with(&mut rand::rng()) } /// Evaluate and roll the dices with provided rng source @@ -286,7 +286,7 @@ impl Roller { /// let r = Roller::new("1d6 + 1d4 + 1d10 + 1d20").unwrap(); /// assert_eq!(vec!["1d6", "1d4", "1d10", "1d20"], r.dices().expect("Error on parse").collect::>()); /// ``` - pub fn dices(&self) -> Result { + pub fn dices(&self) -> Result> { let pairs = RollParser::parse(Rule::command, &self.0)? .next() .unwrap()