Last active
January 7, 2023 02:55
-
-
Save pahosler/e7bd7095571c4495196fefec6f88a95f to your computer and use it in GitHub Desktop.
tokio interval
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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