Trait NumTimeDuration

Source
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§

Source

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));
Source

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));
Source

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));
Source

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));
Source

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));
Source

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));
Source

fn days(&self) -> Duration

Creates a new Duration from the specified number of days.

use num_time_duration::NumTimeDuration;
use std::time::Duration;

assert_eq!(1.days(), Duration::from_secs(86400));
Source

fn weeks(&self) -> Duration

Creates a new Duration from the specified number of weeks.

use num_time_duration::NumTimeDuration;
use std::time::Duration;

assert_eq!(1.weeks(), Duration::from_secs(604800));

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.

Implementations on Foreign Types§

Source§

impl NumTimeDuration for i32

Implementors§