std-method
Duration::subsec_millis, subsec_micros and subsec_nanos
Read only the fractional portion of a second. This is useful for composing a timestamp display when seconds are handled separately. Smaller fractional units are truncated. Expected stdout (not executed): 123 123456 123456789 Common mistake: Interpreting subsec_millis as the entire interval in milliseconds.
Formal Syntax & Structure
rust syntaxrust
d.subsec_millis() -> u32; d.subsec_micros() -> u32; d.subsec_nanos() -> u32Working Example
Example Snippetrust
fn main() { use std::time::Duration; let d = Duration::new(5, 123_456_789); println!("{} {} {}", d.subsec_millis(), d.subsec_micros(), d.subsec_nanos());}