std-type
Duration: nonnegative time intervals
A Duration stores whole seconds and a fractional nanosecond component. It cannot describe a negative interval. Use it for limits, intervals and elapsed-time measurements. The unit of the input matters. Expected stdout (not executed): 1 500 Common mistake: Treating 1500 milliseconds as 1500 seconds.
Formal Syntax & Structure
rust syntaxrust
pub struct Duration { /* private fields */ }Working Example
Example Snippetrust
fn main() { use std::time::Duration; let interval = Duration::from_millis(1500); println!("{} {}", interval.as_secs(), interval.subsec_millis());}