expression

Advance simulated time explicitly

Jump the paused Tokio clock forward. Advancing time is not a synchronization barrier for all timer-triggered work. This fixture checks the clock rather than assuming a background task completed. Tokio is an external dependency; see the proposed Cargo manifest. Expected stdout (not executed): 4 Common mistake: Assuming every awakened task finishes before advance returns.

Formal Syntax & Structure

rust syntaxrust
tokio::time::advance(duration).await

Working Example

Example Snippetrust
#[tokio::main(flavor = "current_thread", start_paused = true)]async fn main() {    use tokio::time::{advance, Duration, Instant};    let start = Instant::now();    advance(Duration::from_secs(4)).await;    println!("{}", start.elapsed().as_secs());}
Rust Reference