Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to rand 0.9 #215

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ members = ["examples/*"]
[dependencies]
bytes = "1.4"
indexmap = "2"
rand = { version = "0.8.5", features = ["small_rng"] }
rand_distr = "0.4.3"
rand = { version = "0.9", features = ["small_rng"] }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little fuzzy on cargo resolver. Will this break consumers who also declare a dependency on 0.8?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems a breaking change as rand updated rand_core and rand_core::RngCore is exposed at the Builder::build_with_rng.

https://docs.rs/turmoil/0.6.5/turmoil/struct.Builder.html#method.build_with_rng

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's stash this one and we can bundle it when we go to 0.7?

rand_distr = "0.5"
regex = { version = "1", optional = true }
scoped-tls = "1.0.1"
tokio = { version = "1.25.0", features = ["full", "test-util"] }
Expand Down
2 changes: 1 addition & 1 deletion src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ impl Builder {
///
/// This will use default rng with entropy from the device running.
pub fn build<'a>(&self) -> Sim<'a> {
self.build_with_rng(Box::new(rand::rngs::SmallRng::from_entropy()))
self.build_with_rng(Box::new(rand::rngs::SmallRng::from_os_rng()))
}

/// Build a sim with a provided `rng`.
Expand Down
2 changes: 1 addition & 1 deletion src/sim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ mod test {
})
};

let construct_a_first = sim.world.borrow_mut().rng.gen_bool(0.5);
let construct_a_first = sim.world.borrow_mut().rng.random_bool(0.5);
if construct_a_first {
make_a(&mut sim);
make_b(&mut sim);
Expand Down
4 changes: 2 additions & 2 deletions src/top.rs
Original file line number Diff line number Diff line change
Expand Up @@ -507,13 +507,13 @@ impl Link {
fn rand_partition(&self, global: &config::MessageLoss, rand: &mut dyn RngCore) -> bool {
let config = self.config.message_loss.as_ref().unwrap_or(global);
let fail_rate = config.fail_rate;
fail_rate > 0.0 && rand.gen_bool(fail_rate)
fail_rate > 0.0 && rand.random_bool(fail_rate)
}

fn rand_repair(&self, global: &config::MessageLoss, rand: &mut dyn RngCore) -> bool {
let config = self.config.message_loss.as_ref().unwrap_or(global);
let repair_rate = config.repair_rate;
repair_rate > 0.0 && rand.gen_bool(repair_rate)
repair_rate > 0.0 && rand.random_bool(repair_rate)
}

fn delay(&self, global: &config::Latency, rand: &mut dyn RngCore) -> Duration {
Expand Down