How to pause execution for 5 seconds in Rust

1 Answer

0 votes
use std::thread;
use std::time::Duration;

fn main() {
    println!("Pausing for 5 seconds...");
    
    thread::sleep(Duration::from_secs(5));
    
    println!("Resuming execution.");
}



/*
run:

Pausing for 5 seconds...
Resuming execution.

*/

 



answered Apr 30 by avibootz

Related questions

1 answer 47 views
2 answers 50 views
1 answer 49 views
1 answer 41 views
1 answer 45 views
2 answers 44 views
1 answer 35 views
...