Skip to content

Instantly share code, notes, and snippets.

@pahosler
Last active January 7, 2023 02:55
Show Gist options
  • Save pahosler/e7bd7095571c4495196fefec6f88a95f to your computer and use it in GitHub Desktop.
Save pahosler/e7bd7095571c4495196fefec6f88a95f to your computer and use it in GitHub Desktop.
tokio interval
use tokio::time;
#[tokio::main]
async fn main() {
let mut interval = time::interval(time::Duration::from_secs(1));
let mut c = 10;
loop {
interval.tick().await;
println!("{c}");
c = c - 1;
if c == 0 {
break;
}
}
println!("Hello, world!");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment