We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents e10f0b1 + bbc33ac commit 330fa40Copy full SHA for 330fa40
src/libstd/thread/mod.rs
@@ -394,6 +394,19 @@ pub fn sleep_ms(ms: u32) {
394
/// signal being received or a spurious wakeup. Platforms which do not support
395
/// nanosecond precision for sleeping will have `dur` rounded up to the nearest
396
/// granularity of time they can sleep for.
397
+///
398
+/// # Examples
399
400
+/// ```
401
+/// use std::{thread, time};
402
403
+/// let ten_millis = time::Duration::from_millis(10);
404
+/// let now = time::Instant::now();
405
406
+/// thread::sleep(ten_millis);
407
408
+/// assert!(now.elapsed() >= ten_millis);
409
410
#[stable(feature = "thread_sleep", since = "1.4.0")]
411
pub fn sleep(dur: Duration) {
412
imp::Thread::sleep(dur)
0 commit comments