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, 2025 by avibootz

Related questions

1 answer 148 views
2 answers 166 views
1 answer 161 views
1 answer 117 views
117 views asked Apr 30, 2025 by avibootz
1 answer 138 views
2 answers 142 views
1 answer 125 views
...