Answers for "how to sleep in rust"

1

rust lang sleep

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

fn main() {
    sleep(Duration::from_millis(2));
}
Posted by: Guest on April-18-2021
0

rust sleep

use std::{thread, time};

loop {
    let ten_millis = time::Duration::from_millis(10);
    let now = time::Instant::now();
    thread::sleep(ten_millis);
}
Posted by: Guest on November-12-2021

Browse Popular Code Answers by Language