main.rs 364 B

1234567891011121314151617
  1. use tokio::signal;
  2. async fn say_world() {
  3. println!("world");
  4. }
  5. #[tokio::main(flavor = "current_thread")]
  6. async fn main() {
  7. // Calling `say_world()` does not execute the body of `say_world()`.
  8. let op = say_world();
  9. // This println! comes first
  10. println!("hello");
  11. // Calling `.await` on `op` starts executing `say_world`.
  12. op.await;
  13. }