expression
Choose the initial interval deadline
Set the first scheduled tick explicitly, rather than accepting an immediately available first tick. Use this for a delayed periodic task. Tokio is an external dependency; see the proposed Cargo manifest. Expected stdout (not executed): true 4 Common mistake: Using a zero period; interval construction requires a nonzero duration.
Formal Syntax & Structure
rust syntaxrust
tokio::time::interval_at(start, period)Working Example
Example Snippetrust
#[tokio::main(flavor = "current_thread", start_paused = true)]async fn main() { use tokio::time::{interval_at, Duration, Instant}; let start = Instant::now() + Duration::from_secs(3); let mut ticks = interval_at(start, Duration::from_secs(4)); let first = ticks.tick().await; let second = ticks.tick().await; println!("{} {}", first == start, (second - first).as_secs());}