expression

Paused Tokio clock for reproducible examples

Use a paused current-thread runtime with the time and test-util features in controlled fixtures. The runtime can advance simulated time when no runnable work remains. It does not pause the host clock. Tokio is an external dependency; see the proposed Cargo manifest. Expected stdout (not executed): true Common mistake: Expecting the host clock or std::time::Instant to freeze too.

Formal Syntax & Structure

rust syntaxrust
#[tokio::main(flavor = "current_thread", start_paused = true)]

Working Example

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