From 77844f015f0f3277517f1a5f18404d0777a60274 Mon Sep 17 00:00:00 2001 From: dvdsk Date: Sun, 16 Jul 2023 11:32:22 +0200 Subject: [PATCH] fixes sleep_until examples --- library/std/src/thread/mod.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/library/std/src/thread/mod.rs b/library/std/src/thread/mod.rs index 7cbd7a8a2f6..35f4cb64178 100644 --- a/library/std/src/thread/mod.rs +++ b/library/std/src/thread/mod.rs @@ -893,6 +893,9 @@ pub fn sleep(dur: Duration) { /// # use std::time::{Duration, Instant}; /// # use std::thread; /// # +/// # fn update() {} +/// # fn render() {} +/// # /// let max_fps = 60.0; /// let frame_time = Duration::from_secs_f32(1.0/max_fps); /// let mut next_frame = Instant::now(); @@ -912,6 +915,8 @@ pub fn sleep(dur: Duration) { /// # use std::time::{Duration, Instant}; /// # use std::thread; /// # +/// # fn slow_web_api_call() {} +/// # /// # const MAX_DURATION: Duration = Duration::from_secs(10); /// # /// let deadline = Instant::now() + MAX_DURATION; @@ -919,10 +924,10 @@ pub fn sleep(dur: Duration) { /// let mut next_attempt = Instant::now(); /// loop { /// if Instant::now() > deadline { -/// break Err(()), +/// break Err(()); /// } /// if let Ready(data) = slow_web_api_call() { -/// break Ok(data), +/// break Ok(data); /// } /// /// next_attempt = deadline.min(next_attempt + delay);