Skip to content

Commit

Permalink
Merge pull request #167 from andrewwhitehead/upd-rand
Browse files Browse the repository at this point in the history
Update rand to 0.8
  • Loading branch information
Alexei-Kornienko committed Aug 13, 2022
2 parents f9516a1 + ef55529 commit d9edd60
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ futures = "0.3"
futures-util = "0.3"
async-trait = "0.1"
parking_lot = "0.11"
rand = "0.7"
rand = "0.8"
bytes = "1"
tokio = { version = "1", features = ["full"], optional = true }
tokio-util = { version = "0.6", features = ["compat"], optional = true }
Expand All @@ -40,7 +40,7 @@ async-std = { version = "1", features = ["attributes"], optional = true }
chrono = "0.4"
criterion = "0.3"
pretty_env_logger = "0.4"
zmq2= "0.5.0"
zmq2 = "0.5.0"
hex = "0.4.3"


Expand Down
2 changes: 1 addition & 1 deletion examples/stock_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("Start sending loop");
loop {
for stock in &stocks {
let price: u32 = rng.gen_range(1, 100);
let price: u32 = rng.gen_range(1..100);
let mut m: ZmqMessage = ZmqMessage::from(*stock);
m.push_back(price.to_ne_bytes().to_vec().into());
dbg!(m.clone());
Expand Down
2 changes: 1 addition & 1 deletion examples/task_ventilator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
let mut rnd = rand::thread_rng();
let mut total_msec = 0;
for _ in 0..100 {
let workload = rnd.gen_range(1, 100);
let workload = rnd.gen_range(1..100);
sender.send(workload.to_string().into()).await?;
total_msec += workload;
}
Expand Down
6 changes: 3 additions & 3 deletions examples/weather_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {

println!("Start sending loop");
loop {
let zipcode = rng.gen_range(10000, 10010);
let temperature = rng.gen_range(-80, 135);
let relhumidity = rng.gen_range(10, 60);
let zipcode = rng.gen_range(10000..10010);
let temperature = rng.gen_range(-80..135);
let relhumidity = rng.gen_range(10..60);
socket
.send(format!("{} {} {}", zipcode, temperature, relhumidity).into())
.await?;
Expand Down
2 changes: 1 addition & 1 deletion src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ pub(crate) async fn connect_forever(endpoint: Endpoint) -> ZmqResult<(FramedIo,
}
let delay = {
let mut rng = rand::thread_rng();
std::f64::consts::E.pow(try_num as f64 / 3.0) + rng.gen_range(0.0f64, 0.1f64)
std::f64::consts::E.pow(try_num as f64 / 3.0) + rng.gen_range(0.0f64..0.1f64)
};
async_rt::task::sleep(std::time::Duration::from_secs_f64(delay)).await;
continue;
Expand Down

0 comments on commit d9edd60

Please sign in to comment.