Skip to content

Commit 77844f0

Browse files
committed
fixes sleep_until examples
1 parent 4854fc9 commit 77844f0

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

library/std/src/thread/mod.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -893,6 +893,9 @@ pub fn sleep(dur: Duration) {
893893
/// # use std::time::{Duration, Instant};
894894
/// # use std::thread;
895895
/// #
896+
/// # fn update() {}
897+
/// # fn render() {}
898+
/// #
896899
/// let max_fps = 60.0;
897900
/// let frame_time = Duration::from_secs_f32(1.0/max_fps);
898901
/// let mut next_frame = Instant::now();
@@ -912,17 +915,19 @@ pub fn sleep(dur: Duration) {
912915
/// # use std::time::{Duration, Instant};
913916
/// # use std::thread;
914917
/// #
918+
/// # fn slow_web_api_call() {}
919+
/// #
915920
/// # const MAX_DURATION: Duration = Duration::from_secs(10);
916921
/// #
917922
/// let deadline = Instant::now() + MAX_DURATION;
918923
/// let delay = Duration::from_millis(250);
919924
/// let mut next_attempt = Instant::now();
920925
/// loop {
921926
/// if Instant::now() > deadline {
922-
/// break Err(()),
927+
/// break Err(());
923928
/// }
924929
/// if let Ready(data) = slow_web_api_call() {
925-
/// break Ok(data),
930+
/// break Ok(data);
926931
/// }
927932
///
928933
/// next_attempt = deadline.min(next_attempt + delay);

0 commit comments

Comments
 (0)