std-method

Duration::ZERO, MAX and is_zero

ZERO is an empty interval and MAX is the largest representable Duration, not the largest interval accepted by every clock or OS. Default also yields zero. Test zero before computing a reciprocal rate. Expected stdout (not executed): true true Common mistake: Using Duration::MAX as an automatically portable infinite timeout.

Formal Syntax & Structure

rust syntaxrust
Duration::ZERO; Duration::MAX; d.is_zero() -> bool

Working Example

Example Snippetrust
fn main() {    use std::time::Duration;    println!("{} {}", Duration::default().is_zero(), Duration::MAX > Duration::ZERO);}
Rust Reference