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 3secs > 0.001
=> milliseconds with precision 3secs > 0.000_001
=> microseconds with precision 3- otherwise => nanoseconds
By default the duration is formatted using abbreviated units
(e.g. 1.234ms
).
If the the format string is specified with the alternate flag {:#}
,
the duration is formatted using the full unit name instead
(e.g. 1.234 milliseconds
).
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µs"); let alternate = format!("{:#}", TimeFormat(dur)); assert_eq!(alternate, "461.933 microseconds");
Trait Implementations
impl<T: Clone + Borrow<Duration>> Clone for TimeFormat<T>
[src]
fn clone(&self) -> TimeFormat<T>
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
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]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl<T: Borrow<Duration>> Display for TimeFormat<T>
[src]
Auto Trait Implementations
impl<T> Send for TimeFormat<T> where
T: Send,
T: Send,
impl<T> Sync for TimeFormat<T> where
T: Sync,
T: Sync,