Trait core_extensions::integers::ToTime
source · [−]pub trait ToTime {
fn hours(self) -> Duration;
fn minutes(self) -> Duration;
fn seconds(self) -> Duration;
fn milliseconds(self) -> Duration;
fn microseconds(self) -> Duration;
fn nanoseconds(self) -> Duration;
}
Available on crate feature
integers
only.Expand description
Converts an integer to a Duration of the unit.
Required Methods
sourcefn milliseconds(self) -> Duration
fn milliseconds(self) -> Duration
sourcefn microseconds(self) -> Duration
fn microseconds(self) -> Duration
sourcefn nanoseconds(self) -> Duration
fn nanoseconds(self) -> Duration
Creates a Duration
of self
nanoseconds
Example
use core_extensions::ToTime;
use std::time::Duration;
assert_eq!(10.nanoseconds(), Duration::new(0,10));
assert_eq!(1_000_000.nanoseconds(), Duration::new(0,1_000_000));
assert_eq!(1_000_000_000.nanoseconds(), Duration::new(1,0));
assert_eq!(1_000_001_000.nanoseconds(), Duration::new(1,1_000));