We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
std::thread::sleep
1 parent fe96928 commit bbc33acCopy full SHA for bbc33ac
src/libstd/thread/mod.rs
@@ -379,6 +379,19 @@ pub fn sleep_ms(ms: u32) {
379
/// signal being received or a spurious wakeup. Platforms which do not support
380
/// nanosecond precision for sleeping will have `dur` rounded up to the nearest
381
/// granularity of time they can sleep for.
382
+///
383
+/// # Examples
384
385
+/// ```
386
+/// use std::{thread, time};
387
388
+/// let ten_millis = time::Duration::from_millis(10);
389
+/// let now = time::Instant::now();
390
391
+/// thread::sleep(ten_millis);
392
393
+/// assert!(now.elapsed() >= ten_millis);
394
395
#[stable(feature = "thread_sleep", since = "1.4.0")]
396
pub fn sleep(dur: Duration) {
397
imp::Thread::sleep(dur)
0 commit comments