0

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.

cafce25
  • 15,907
  • 4
  • 25
  • 31
zoloadang
  • 1
  • 2

0 Answers0