Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
4 changes: 2 additions & 2 deletions src/cards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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);
}

Expand Down
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ':';

Expand Down Expand Up @@ -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)
}
}

Expand All @@ -201,7 +201,7 @@ impl Roller {

/// Evaluate and roll the dices with default Rng source (`rand::thread_rng()`)
pub fn roll(&self) -> Result<RollResult> {
self.roll_with(&mut rand::thread_rng())
self.roll_with(&mut rand::rng())
}

/// Evaluate and roll the dices with provided rng source
Expand Down Expand Up @@ -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::<Vec<_>>());
/// ```
pub fn dices(&self) -> Result<Dices> {
pub fn dices(&self) -> Result<Dices<'_>> {
let pairs = RollParser::parse(Rule::command, &self.0)?
.next()
.unwrap()
Expand Down