pub trait NumTimeDuration: PrimInt {
// Required methods
fn nanoseconds(&self) -> Duration;
fn microseconds(&self) -> Duration;
fn milliseconds(&self) -> Duration;
fn seconds(&self) -> Duration;
fn minutes(&self) -> Duration;
fn hours(&self) -> Duration;
fn days(&self) -> Duration;
fn weeks(&self) -> Duration;
}
Required Methods§
Sourcefn nanoseconds(&self) -> Duration
fn nanoseconds(&self) -> Duration
Creates a new Duration from the specified number of nanoseconds.
use num_time_duration::NumTimeDuration;
use std::time::Duration;
assert_eq!(1.nanoseconds(), Duration::from_nanos(1));
Sourcefn microseconds(&self) -> Duration
fn microseconds(&self) -> Duration
Creates a new Duration from the specified number of microseconds.
use num_time_duration::NumTimeDuration;
use std::time::Duration;
assert_eq!(1.microseconds(), Duration::from_micros(1));
Sourcefn milliseconds(&self) -> Duration
fn milliseconds(&self) -> Duration
Creates a new Duration from the specified number of milliseconds.
use num_time_duration::NumTimeDuration;
use std::time::Duration;
assert_eq!(1.milliseconds(), Duration::from_millis(1));
Sourcefn seconds(&self) -> Duration
fn seconds(&self) -> Duration
Creates a new Duration from the specified number of seconds.
use num_time_duration::NumTimeDuration;
use std::time::Duration;
assert_eq!(1.seconds(), Duration::from_secs(1));
Sourcefn minutes(&self) -> Duration
fn minutes(&self) -> Duration
Creates a new Duration from the specified number of minutes.
use num_time_duration::NumTimeDuration;
use std::time::Duration;
assert_eq!(1.minutes(), Duration::from_secs(60));
Sourcefn hours(&self) -> Duration
fn hours(&self) -> Duration
Creates a new Duration from the specified number of hours.
use num_time_duration::NumTimeDuration;
use std::time::Duration;
assert_eq!(1.hours(), Duration::from_secs(3600));
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.