0

I am new to Rust and I have a question...

Question: What is Rust's equivalent of Python's time.sleep()? I have been searching around the web and the best I am finding is something similar to to this...

use std::time;
Thread::sleep(time::Duration::new(5, 0));

But this seems to be only for threads, is that correct, or am I just dumb?

  • 2
    A process at least has the main thread, in this case it's just that Rust is more explicit with the way they've named the functionality. – Menace Jul 30 '22 at 16:57
  • 2
    Adding to @Lightning's comment: You don't need to spawn a thread to be on a thread. You are always on a thread, because that's what executes your code. If you spawn a thread, you now have two threads, which is called *multi-threading*. Not spawning a thread is called *single-threading*. – Finomnis Jul 30 '22 at 17:07
  • If it worked for you, you can accept the linked answer as duplicate – Finomnis Jul 30 '22 at 17:34

0 Answers0