Trait NumericalDuration
trait NumericalDuration: sealed::Sealed
Create Durations from numeric literals.
Examples
Basic construction of Durations.
# use ;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
Signed integers work as well!
# use ;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
Just like any other Duration, they can be added, subtracted, etc.
# use NumericalDuration;
assert_eq!;
assert_eq!;
When called on floating point values, any remainder of the floating point value will be truncated. Keep in mind that floating point numbers are inherently imprecise and have limited capacity.
Required Methods
fn nanoseconds(self: Self) -> DurationCreate a
Durationfrom the number of nanoseconds.fn microseconds(self: Self) -> DurationCreate a
Durationfrom the number of microseconds.fn milliseconds(self: Self) -> DurationCreate a
Durationfrom the number of milliseconds.fn seconds(self: Self) -> DurationCreate a
Durationfrom the number of seconds.fn minutes(self: Self) -> DurationCreate a
Durationfrom the number of minutes.fn hours(self: Self) -> DurationCreate a
Durationfrom the number of hours.fn days(self: Self) -> DurationCreate a
Durationfrom the number of days.fn weeks(self: Self) -> DurationCreate a
Durationfrom the number of weeks.
Implementors
impl NumericalDuration for f64impl NumericalDuration for i64