Logo

Programming-Idioms

History of Idiom 45 > diff from v42 to v43

Edit summary for version 43 by natejms:
[Rust] Demo link doesn't lead to intended page

Version 42

2017-05-16, 19:12:36

Version 43

2017-05-16, 19:14:43

Idiom #45 Pause execution for 5 seconds

Sleep for 5 seconds in current thread, before proceeding with next instructions.

Illustration

Idiom #45 Pause execution for 5 seconds

Sleep for 5 seconds in current thread, before proceeding with next instructions.

Illustration
Imports
use std::{thread, time};
Imports
use std::{thread, time};
Code
thread::sleep(time::Duration::from_millis(5000));
Code
thread::sleep(time::Duration::from_millis(5000));
Doc URL
https://doc.rust-lang.org/std/thread/fn.sleep.html
Doc URL
https://doc.rust-lang.org/std/thread/fn.sleep.html
Demo URL
https://play.rust-lang.org/?code=fn%20main()%20%7B%0Ause%20std%3A%3A%7Bthread%2C%20time%7D%3B%0A%0Alet%20ten_millis%20%3D%20time%3A%3ADuration%3A%3Afrom_millis(10)%3B%0Alet%20now%20%3D%20time%3A%3AInstant%3A%3Anow()%3B%0A%0Athread%3A%3Asleep(ten_mill