[−][src]Trait core_extensions::integer_extensions::ToTime
Converts an integer to a Duration of the unit.
Required methods
fn hours(self) -> Duration
Creates a ::std::time::Duration of self
hours.
Example
use core_extensions::integer_extensions::{ToTime}; use std::time::Duration; assert_eq!(1 .hours(),Duration::from_secs(1 *3600)); assert_eq!(10 .hours(),Duration::from_secs(10 *3600)); assert_eq!(101.hours(),Duration::from_secs(101*3600));
fn minutes(self) -> Duration
Creates a ::std::time::Duration of self
minutes.
Example
use core_extensions::integer_extensions::{ToTime}; use std::time::Duration; assert_eq!(1 .minutes(),Duration::from_secs(1 *60)); assert_eq!(10 .minutes(),Duration::from_secs(10 *60)); assert_eq!(101.minutes(),Duration::from_secs(101*60));
fn seconds(self) -> Duration
Creates a ::std::time::Duration of self
seconds
Example
use core_extensions::integer_extensions::{ToTime}; use std::time::Duration; assert_eq!(1.seconds(),Duration::from_secs(1)); assert_eq!(10.seconds(),Duration::from_secs(10)); assert_eq!(101.seconds(),Duration::from_secs(101));
fn miliseconds(self) -> Duration
Creates a ::std::time::Duration of self
miliseconds
Example
use core_extensions::integer_extensions::{ToTime}; use std::time::Duration; assert_eq!(0.miliseconds(),Duration::from_millis(0)); assert_eq!(1.miliseconds(),Duration::from_millis(1)); assert_eq!(10.miliseconds(),Duration::from_millis(10));
fn microseconds(self) -> Duration
Creates a ::std::time::Duration of self
microseconds
Example
use core_extensions::integer_extensions::{ToTime}; use std::time::Duration; assert_eq!(10.microseconds(),Duration::new(0,10_000)); assert_eq!(10_000_001.microseconds(),Duration::new(10,1_000));
fn nanoseconds(self) -> Duration
Creates a ::std::time::Duration of self
nanoseconds
Example
use core_extensions::integer_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));
Implementors
impl<T> ToTime for T where
T: IntegerExt + Copy,
<T as IntegerExt>::Unsigned: Into<u64>,
[src]
T: IntegerExt + Copy,
<T as IntegerExt>::Unsigned: Into<u64>,