Struct floating_duration::TimeFormat [] [src]

pub struct TimeFormat<T: Borrow<Duration>>(pub T);

A formatting newtype for providing a Display implementation. This format is meant to be used for printing performance measurements.

Behaviour

  • secs > 0 => seconds with precision 3
  • secs > 0.001 => milliseconds with precision 3
  • secs > 0.000_001 => microseconds with precision 3
  • otherwise => nanoseconds

Examples

use std::time::Duration;
use floating_duration::TimeFormat;

let dur = Duration::new(0, 461_933);
let formatted = format!("{}", TimeFormat(dur));
assert_eq!(formatted, "461.933 microseconds");

Trait Implementations

impl<T: Clone + Borrow<Duration>> Clone for TimeFormat<T>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<T: Copy + Borrow<Duration>> Copy for TimeFormat<T>
[src]

impl<T: Debug + Borrow<Duration>> Debug for TimeFormat<T>
[src]

Formats the value using the given formatter.

impl<T: Borrow<Duration>> Display for TimeFormat<T>
[src]

Formats the value using the given formatter. Read more