macro_rules! assert_elapsed {
    ($start:expr, $dur:expr) => { ... };
    ($start:expr, $dur:expr, $margin_of_error:expr) => { ... };
}
Expand description

Given an Instant and a Duration, assert time elapsed since Instant is equal to Duration. This macro allows for a 5ms margin of error.

Example

let now = std::time::Instant::now();
let _ = some_function_that_always_takes_five_seconds_to_run().await;
assert_elapsed!(now, std::time::Duration::from_secs(5));