std-type

Instant: opaque monotonic clock readings

An Instant is a local reading of a monotonic clock. Compare instants and compute intervals; do not treat the opaque representation as a Unix timestamp. Clock rate and suspend behavior depend on the platform. This example uses a reading as an anchor rather than asserting a real elapsed time. Expected stdout (not executed): true Common mistake: Saving an Instant as a portable date or expecting nanosecond accuracy.

Formal Syntax & Structure

rust syntaxrust
Instant::now() -> Instant

Working Example

Example Snippetrust
fn main() {    use std::time::{Duration, Instant};    let start = Instant::now();    let later = start.checked_add(Duration::from_secs(2)).unwrap();    println!("{}", later > start);}
Rust Reference