I have just used Rust for a short time, before I was engaged in javascript development, I often use setTimeout
to specify a timer to simulate a time-consuming logic, so how to implement a timer like this in rust?
like this:
setTimeout(function(){ /*code snip*/ }, 1000);
I try to use the std::thread::sleep
method of the thread, but it will block the current thread and cannot simulate the asynchronous state.