Skip to content

Commit

Permalink
Update time::delay_for to time::sleep
Browse files Browse the repository at this point in the history
  • Loading branch information
udoprog committed Mar 15, 2021
1 parent f68b620 commit a6b6651
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion scripts/async.rn
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ struct Timeout;

async fn test(timeout, helpful_hint) {
let request = http::get(`http://httpstat.us/200?sleep=${timeout}`);
let timeout = time::delay_for(time::Duration::from_secs(2));
let timeout = time::sleep(time::Duration::from_secs(2));

let result = select {
_ = timeout => Err(Timeout),
Expand Down
2 changes: 1 addition & 1 deletion scripts/book/async/async_http_concurrent.rn
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ struct Timeout;

async fn request(timeout) {
let request = http::get(`http://httpstat.us/200?sleep=${timeout}`);
let timeout = time::delay_for(time::Duration::from_secs(2));
let timeout = time::sleep(time::Duration::from_secs(2));

let result = select {
_ = timeout => Err(Timeout),
Expand Down
2 changes: 1 addition & 1 deletion scripts/book/async/async_http_timeout.rn
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ struct Timeout;

async fn request(timeout) {
let request = http::get(`http://httpstat.us/200?sleep=${timeout}`);
let timeout = time::delay_for(time::Duration::from_secs(2));
let timeout = time::sleep(time::Duration::from_secs(2));

let result = select {
_ = timeout => Err(Timeout),
Expand Down
2 changes: 1 addition & 1 deletion scripts/book/loops/loop_forever.rn
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ use time::Duration;
pub async fn main() {
loop {
println("Hello forever!");
time::delay_for(Duration::from_secs(1)).await;
time::sleep(Duration::from_secs(1)).await;
}
}

0 comments on commit a6b6651

Please sign in to comment.