Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUST

sleep in rust

use std::thread::sleep;
use std::time::Duration;

fn main() {
  fn set_timeout(callback: fn() -> (), time: u64) -> () {
    sleep(Duration::from_secs(time));
    callback();
  }

  set_timeout(|| {
    println!("Hello World after 3 secs");
  }, 3)
}
Source by doc.rust-lang.org #
 
PREVIOUS NEXT
Tagged: #sleep #rust
ADD COMMENT
Topic
Name
1+4 =