std-module
std::time: selecting a clock
Choose a type by the question: Duration is an interval, Instant measures local elapsed time, and SystemTime represents wall-clock time. Only the latter can be related to a Unix timestamp. The sample computes a fixed interval from a known epoch. Expected stdout (not executed): 90 Common mistake: Using a wall clock to enforce an elapsed-time budget.
Formal Syntax & Structure
rust syntaxrust
use std::time::{Duration, Instant, SystemTime};Working Example
Example Snippetrust
fn main() { use std::time::{Duration, UNIX_EPOCH}; let event = UNIX_EPOCH + Duration::from_secs(90); println!("{}", event.duration_since(UNIX_EPOCH).unwrap().as_secs());}