time

Struct Duration

Source
pub struct Duration { /* private fields */ }
Expand description

A span of time with nanosecond precision.

Each Duration is composed of a whole number of seconds and a fractional part represented in nanoseconds.

This implementation allows for negative durations, unlike core::time::Duration.

Implementations§

Source§

impl Duration

Source

pub const ZERO: Self = _

Equivalent to 0.seconds().

assert_eq!(Duration::ZERO, 0.seconds());
Source

pub const NANOSECOND: Self = _

Equivalent to 1.nanoseconds().

assert_eq!(Duration::NANOSECOND, 1.nanoseconds());
Source

pub const MICROSECOND: Self = _

Equivalent to 1.microseconds().

assert_eq!(Duration::MICROSECOND, 1.microseconds());
Source

pub const MILLISECOND: Self = _

Equivalent to 1.milliseconds().

assert_eq!(Duration::MILLISECOND, 1.milliseconds());
Source

pub const SECOND: Self = _

Equivalent to 1.seconds().

assert_eq!(Duration::SECOND, 1.seconds());
Source

pub const MINUTE: Self = _

Equivalent to 1.minutes().

assert_eq!(Duration::MINUTE, 1.minutes());
Source

pub const HOUR: Self = _

Equivalent to 1.hours().

assert_eq!(Duration::HOUR, 1.hours());
Source

pub const DAY: Self = _

Equivalent to 1.days().

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

pub const WEEK: Self = _

Equivalent to 1.weeks().

assert_eq!(Duration::WEEK, 1.weeks());
Source

pub const MIN: Self = _

The minimum possible duration. Adding any negative duration to this will cause an overflow.

Source

pub const MAX: Self = _

The maximum possible duration. Adding any positive duration to this will cause an overflow.

Source

pub const fn is_zero(self) -> bool

Check if a duration is exactly zero.

assert!(0.seconds().is_zero());
assert!(!1.nanoseconds().is_zero());
Source

pub const fn is_negative(self) -> bool

Check if a duration is negative.

assert!((-1).seconds().is_negative());
assert!(!0.seconds().is_negative());
assert!(!1.seconds().is_negative());
Source

pub const fn is_positive(self) -> bool

Check if a duration is positive.

assert!(1.seconds().is_positive());
assert!(!0.seconds().is_positive());
assert!(!(-1).seconds().is_positive());
Source

pub const fn abs(self) -> Self

Get the absolute value of the duration.

This method saturates the returned value if it would otherwise overflow.

assert_eq!(1.seconds().abs(), 1.seconds());
assert_eq!(0.seconds().abs(), 0.seconds());
assert_eq!((-1).seconds().abs(), 1.seconds());
Source

pub const fn unsigned_abs(self) -> StdDuration

Convert the existing Duration to a std::time::Duration and its sign. This returns a std::time::Duration and does not saturate the returned value (unlike Duration::abs).

assert_eq!(1.seconds().unsigned_abs(), 1.std_seconds());
assert_eq!(0.seconds().unsigned_abs(), 0.std_seconds());
assert_eq!((-1).seconds().unsigned_abs(), 1.std_seconds());
Source

pub const fn new(seconds: i64, nanoseconds: i32) -> Self

Create a new Duration with the provided seconds and nanoseconds. If nanoseconds is at least ±109, it will wrap to the number of seconds.

assert_eq!(Duration::new(1, 0), 1.seconds());
assert_eq!(Duration::new(-1, 0), (-1).seconds());
assert_eq!(Duration::new(1, 2_000_000_000), 3.seconds());
§Panics

This may panic if an overflow occurs.

Source

pub const fn weeks(weeks: i64) -> Self

Create a new Duration with the given number of weeks. Equivalent to Duration::seconds(weeks * 604_800).

assert_eq!(Duration::weeks(1), 604_800.seconds());
§Panics

This may panic if an overflow occurs.

Source

pub const fn days(days: i64) -> Self

Create a new Duration with the given number of days. Equivalent to Duration::seconds(days * 86_400).

assert_eq!(Duration::days(1), 86_400.seconds());
§Panics

This may panic if an overflow occurs.

Source

pub const fn hours(hours: i64) -> Self

Create a new Duration with the given number of hours. Equivalent to Duration::seconds(hours * 3_600).

assert_eq!(Duration::hours(1), 3_600.seconds());
§Panics

This may panic if an overflow occurs.

Source

pub const fn minutes(minutes: i64) -> Self

Create a new Duration with the given number of minutes. Equivalent to Duration::seconds(minutes * 60).

assert_eq!(Duration::minutes(1), 60.seconds());
§Panics

This may panic if an overflow occurs.

Source

pub const fn seconds(seconds: i64) -> Self

Create a new Duration with the given number of seconds.

assert_eq!(Duration::seconds(1), 1_000.milliseconds());
Source

pub fn seconds_f64(seconds: f64) -> Self

Creates a new Duration from the specified number of seconds represented as f64.

assert_eq!(Duration::seconds_f64(0.5), 0.5.seconds());
assert_eq!(Duration::seconds_f64(-0.5), (-0.5).seconds());
Source

pub fn seconds_f32(seconds: f32) -> Self

Creates a new Duration from the specified number of seconds represented as f32.

assert_eq!(Duration::seconds_f32(0.5), 0.5.seconds());
assert_eq!(Duration::seconds_f32(-0.5), (-0.5).seconds());
Source

pub fn saturating_seconds_f64(seconds: f64) -> Self

Creates a new Duration from the specified number of seconds represented as f64. Any values that are out of bounds are saturated at the minimum or maximum respectively. NaN gets turned into a Duration of 0 seconds.

assert_eq!(Duration::saturating_seconds_f64(0.5), 0.5.seconds());
assert_eq!(Duration::saturating_seconds_f64(-0.5), (-0.5).seconds());
assert_eq!(
    Duration::saturating_seconds_f64(f64::NAN),
    Duration::new(0, 0),
);
assert_eq!(
    Duration::saturating_seconds_f64(f64::NEG_INFINITY),
    Duration::MIN,
);
assert_eq!(
    Duration::saturating_seconds_f64(f64::INFINITY),
    Duration::MAX,
);
Source

pub fn saturating_seconds_f32(seconds: f32) -> Self

Creates a new Duration from the specified number of seconds represented as f32. Any values that are out of bounds are saturated at the minimum or maximum respectively. NaN gets turned into a Duration of 0 seconds.

assert_eq!(Duration::saturating_seconds_f32(0.5), 0.5.seconds());
assert_eq!(Duration::saturating_seconds_f32(-0.5), (-0.5).seconds());
assert_eq!(
    Duration::saturating_seconds_f32(f32::NAN),
    Duration::new(0, 0),
);
assert_eq!(
    Duration::saturating_seconds_f32(f32::NEG_INFINITY),
    Duration::MIN,
);
assert_eq!(
    Duration::saturating_seconds_f32(f32::INFINITY),
    Duration::MAX,
);
Source

pub fn checked_seconds_f64(seconds: f64) -> Option<Self>

Creates a new Duration from the specified number of seconds represented as f64. Returns None if the Duration can’t be represented.

assert_eq!(Duration::checked_seconds_f64(0.5), Some(0.5.seconds()));
assert_eq!(Duration::checked_seconds_f64(-0.5), Some((-0.5).seconds()));
assert_eq!(Duration::checked_seconds_f64(f64::NAN), None);
assert_eq!(Duration::checked_seconds_f64(f64::NEG_INFINITY), None);
assert_eq!(Duration::checked_seconds_f64(f64::INFINITY), None);
Source

pub fn checked_seconds_f32(seconds: f32) -> Option<Self>

Creates a new Duration from the specified number of seconds represented as f32. Returns None if the Duration can’t be represented.

assert_eq!(Duration::checked_seconds_f32(0.5), Some(0.5.seconds()));
assert_eq!(Duration::checked_seconds_f32(-0.5), Some((-0.5).seconds()));
assert_eq!(Duration::checked_seconds_f32(f32::NAN), None);
assert_eq!(Duration::checked_seconds_f32(f32::NEG_INFINITY), None);
assert_eq!(Duration::checked_seconds_f32(f32::INFINITY), None);
Source

pub const fn milliseconds(milliseconds: i64) -> Self

Create a new Duration with the given number of milliseconds.

assert_eq!(Duration::milliseconds(1), 1_000.microseconds());
assert_eq!(Duration::milliseconds(-1), (-1_000).microseconds());
Source

pub const fn microseconds(microseconds: i64) -> Self

Create a new Duration with the given number of microseconds.

assert_eq!(Duration::microseconds(1), 1_000.nanoseconds());
assert_eq!(Duration::microseconds(-1), (-1_000).nanoseconds());
Source

pub const fn nanoseconds(nanoseconds: i64) -> Self

Create a new Duration with the given number of nanoseconds.

assert_eq!(Duration::nanoseconds(1), 1.microseconds() / 1_000);
assert_eq!(Duration::nanoseconds(-1), (-1).microseconds() / 1_000);
Source

pub const fn whole_weeks(self) -> i64

Get the number of whole weeks in the duration.

assert_eq!(1.weeks().whole_weeks(), 1);
assert_eq!((-1).weeks().whole_weeks(), -1);
assert_eq!(6.days().whole_weeks(), 0);
assert_eq!((-6).days().whole_weeks(), 0);
Source

pub const fn whole_days(self) -> i64

Get the number of whole days in the duration.

assert_eq!(1.days().whole_days(), 1);
assert_eq!((-1).days().whole_days(), -1);
assert_eq!(23.hours().whole_days(), 0);
assert_eq!((-23).hours().whole_days(), 0);
Source

pub const fn whole_hours(self) -> i64

Get the number of whole hours in the duration.

assert_eq!(1.hours().whole_hours(), 1);
assert_eq!((-1).hours().whole_hours(), -1);
assert_eq!(59.minutes().whole_hours(), 0);
assert_eq!((-59).minutes().whole_hours(), 0);
Source

pub const fn whole_minutes(self) -> i64

Get the number of whole minutes in the duration.

assert_eq!(1.minutes().whole_minutes(), 1);
assert_eq!((-1).minutes().whole_minutes(), -1);
assert_eq!(59.seconds().whole_minutes(), 0);
assert_eq!((-59).seconds().whole_minutes(), 0);
Source

pub const fn whole_seconds(self) -> i64

Get the number of whole seconds in the duration.

assert_eq!(1.seconds().whole_seconds(), 1);
assert_eq!((-1).seconds().whole_seconds(), -1);
assert_eq!(1.minutes().whole_seconds(), 60);
assert_eq!((-1).minutes().whole_seconds(), -60);
Source

pub fn as_seconds_f64(self) -> f64

Get the number of fractional seconds in the duration.

assert_eq!(1.5.seconds().as_seconds_f64(), 1.5);
assert_eq!((-1.5).seconds().as_seconds_f64(), -1.5);
Source

pub fn as_seconds_f32(self) -> f32

Get the number of fractional seconds in the duration.

assert_eq!(1.5.seconds().as_seconds_f32(), 1.5);
assert_eq!((-1.5).seconds().as_seconds_f32(), -1.5);
Source

pub const fn whole_milliseconds(self) -> i128

Get the number of whole milliseconds in the duration.

assert_eq!(1.seconds().whole_milliseconds(), 1_000);
assert_eq!((-1).seconds().whole_milliseconds(), -1_000);
assert_eq!(1.milliseconds().whole_milliseconds(), 1);
assert_eq!((-1).milliseconds().whole_milliseconds(), -1);
Source

pub const fn subsec_milliseconds(self) -> i16

Get the number of milliseconds past the number of whole seconds.

Always in the range -999..=999.

assert_eq!(1.4.seconds().subsec_milliseconds(), 400);
assert_eq!((-1.4).seconds().subsec_milliseconds(), -400);
Source

pub const fn whole_microseconds(self) -> i128

Get the number of whole microseconds in the duration.

assert_eq!(1.milliseconds().whole_microseconds(), 1_000);
assert_eq!((-1).milliseconds().whole_microseconds(), -1_000);
assert_eq!(1.microseconds().whole_microseconds(), 1);
assert_eq!((-1).microseconds().whole_microseconds(), -1);
Source

pub const fn subsec_microseconds(self) -> i32

Get the number of microseconds past the number of whole seconds.

Always in the range -999_999..=999_999.

assert_eq!(1.0004.seconds().subsec_microseconds(), 400);
assert_eq!((-1.0004).seconds().subsec_microseconds(), -400);
Source

pub const fn whole_nanoseconds(self) -> i128

Get the number of nanoseconds in the duration.

assert_eq!(1.microseconds().whole_nanoseconds(), 1_000);
assert_eq!((-1).microseconds().whole_nanoseconds(), -1_000);
assert_eq!(1.nanoseconds().whole_nanoseconds(), 1);
assert_eq!((-1).nanoseconds().whole_nanoseconds(), -1);
Source

pub const fn subsec_nanoseconds(self) -> i32

Get the number of nanoseconds past the number of whole seconds.

The returned value will always be in the range -999_999_999..=999_999_999.

assert_eq!(1.000_000_400.seconds().subsec_nanoseconds(), 400);
assert_eq!((-1.000_000_400).seconds().subsec_nanoseconds(), -400);
Source

pub const fn checked_add(self, rhs: Self) -> Option<Self>

Computes self + rhs, returning None if an overflow occurred.

assert_eq!(5.seconds().checked_add(5.seconds()), Some(10.seconds()));
assert_eq!(Duration::MAX.checked_add(1.nanoseconds()), None);
assert_eq!((-5).seconds().checked_add(5.seconds()), Some(0.seconds()));
Source

pub const fn checked_sub(self, rhs: Self) -> Option<Self>

Computes self - rhs, returning None if an overflow occurred.

assert_eq!(5.seconds().checked_sub(5.seconds()), Some(Duration::ZERO));
assert_eq!(Duration::MIN.checked_sub(1.nanoseconds()), None);
assert_eq!(5.seconds().checked_sub(10.seconds()), Some((-5).seconds()));
Source

pub const fn checked_mul(self, rhs: i32) -> Option<Self>

Computes self * rhs, returning None if an overflow occurred.

assert_eq!(5.seconds().checked_mul(2), Some(10.seconds()));
assert_eq!(5.seconds().checked_mul(-2), Some((-10).seconds()));
assert_eq!(5.seconds().checked_mul(0), Some(0.seconds()));
assert_eq!(Duration::MAX.checked_mul(2), None);
assert_eq!(Duration::MIN.checked_mul(2), None);
Source

pub const fn checked_div(self, rhs: i32) -> Option<Self>

Computes self / rhs, returning None if rhs == 0 or if the result would overflow.

assert_eq!(10.seconds().checked_div(2), Some(5.seconds()));
assert_eq!(10.seconds().checked_div(-2), Some((-5).seconds()));
assert_eq!(1.seconds().checked_div(0), None);
Source

pub const fn checked_neg(self) -> Option<Self>

Computes -self, returning None if the result would overflow.

assert_eq!(5.seconds().checked_neg(), Some((-5).seconds()));
assert_eq!(Duration::MIN.checked_neg(), None);
Source

pub const fn saturating_add(self, rhs: Self) -> Self

Computes self + rhs, saturating if an overflow occurred.

assert_eq!(5.seconds().saturating_add(5.seconds()), 10.seconds());
assert_eq!(Duration::MAX.saturating_add(1.nanoseconds()), Duration::MAX);
assert_eq!(
    Duration::MIN.saturating_add((-1).nanoseconds()),
    Duration::MIN
);
assert_eq!((-5).seconds().saturating_add(5.seconds()), Duration::ZERO);
Source

pub const fn saturating_sub(self, rhs: Self) -> Self

Computes self - rhs, saturating if an overflow occurred.

assert_eq!(5.seconds().saturating_sub(5.seconds()), Duration::ZERO);
assert_eq!(Duration::MIN.saturating_sub(1.nanoseconds()), Duration::MIN);
assert_eq!(
    Duration::MAX.saturating_sub((-1).nanoseconds()),
    Duration::MAX
);
assert_eq!(5.seconds().saturating_sub(10.seconds()), (-5).seconds());
Source

pub const fn saturating_mul(self, rhs: i32) -> Self

Computes self * rhs, saturating if an overflow occurred.

assert_eq!(5.seconds().saturating_mul(2), 10.seconds());
assert_eq!(5.seconds().saturating_mul(-2), (-10).seconds());
assert_eq!(5.seconds().saturating_mul(0), Duration::ZERO);
assert_eq!(Duration::MAX.saturating_mul(2), Duration::MAX);
assert_eq!(Duration::MIN.saturating_mul(2), Duration::MIN);
assert_eq!(Duration::MAX.saturating_mul(-2), Duration::MIN);
assert_eq!(Duration::MIN.saturating_mul(-2), Duration::MAX);

Trait Implementations§

Source§

impl Add<Duration> for Date

Source§

fn add(self, duration: Duration) -> Self::Output

§Panics

This may panic if an overflow occurs.

Source§

type Output = Date

The resulting type after applying the + operator.
Source§

impl Add<Duration> for Duration

Source§

fn add(self, std_duration: StdDuration) -> Self::Output

§Panics

This may panic if an overflow occurs.

Source§

type Output = Duration

The resulting type after applying the + operator.
Source§

impl Add<Duration> for Duration

Source§

type Output = Duration

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Duration) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<Duration> for Instant

Source§

type Output = Instant

The resulting type after applying the + operator.
Source§

fn add(self, duration: Duration) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<Duration> for OffsetDateTime

Source§

fn add(self, duration: Duration) -> Self::Output

§Panics

This may panic if an overflow occurs.

Source§

type Output = OffsetDateTime

The resulting type after applying the + operator.
Source§

impl Add<Duration> for PrimitiveDateTime

Source§

fn add(self, duration: Duration) -> Self::Output

§Panics

This may panic if an overflow occurs.

Source§

type Output = PrimitiveDateTime

The resulting type after applying the + operator.
Source§

impl Add<Duration> for SystemTime

Source§

type Output = SystemTime

The resulting type after applying the + operator.
Source§

fn add(self, duration: Duration) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<Duration> for Time

Source§

fn add(self, duration: Duration) -> Self::Output

Add the sub-day time of the Duration to the Time. Wraps on overflow.

assert_eq!(time!(12:00) + 2.hours(), time!(14:00));
assert_eq!(time!(0:00:01) + (-2).seconds(), time!(23:59:59));
Source§

type Output = Time

The resulting type after applying the + operator.
Source§

impl Add for Duration

Source§

fn add(self, rhs: Self) -> Self::Output

§Panics

This may panic if an overflow occurs.

Source§

type Output = Duration

The resulting type after applying the + operator.
Source§

impl AddAssign<Duration> for Date

Source§

fn add_assign(&mut self, rhs: Duration)

Performs the += operation. Read more
Source§

impl AddAssign<Duration> for Duration

Source§

fn add_assign(&mut self, rhs: StdDuration)

Performs the += operation. Read more
Source§

impl AddAssign<Duration> for Duration

Source§

fn add_assign(&mut self, rhs: Duration)

§Panics

This may panic if the resulting addition cannot be represented.

Source§

impl AddAssign<Duration> for Instant

Source§

fn add_assign(&mut self, rhs: Duration)

Performs the += operation. Read more
Source§

impl AddAssign<Duration> for OffsetDateTime

Source§

fn add_assign(&mut self, rhs: Duration)

§Panics

This may panic if an overflow occurs.

Source§

impl AddAssign<Duration> for PrimitiveDateTime

Source§

fn add_assign(&mut self, duration: Duration)

§Panics

This may panic if an overflow occurs.

Source§

impl AddAssign<Duration> for SystemTime

Source§

fn add_assign(&mut self, rhs: Duration)

Performs the += operation. Read more
Source§

impl AddAssign<Duration> for Time

Source§

fn add_assign(&mut self, rhs: Duration)

Performs the += operation. Read more
Source§

impl AddAssign for Duration

Source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
Source§

impl Clone for Duration

Source§

fn clone(&self) -> Duration

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Duration

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Duration

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Display for Duration

The format returned by this implementation is not stable and must not be relied upon.

By default this produces an exact, full-precision printout of the duration. For a concise, rounded printout instead, you can use the .N format specifier:

let duration = Duration::new(123456, 789011223);
println!("{duration:.3}");

For the purposes of this implementation, a day is exactly 24 hours and a minute is exactly 60 seconds.

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Div<Duration> for Duration

Source§

type Output = f64

The resulting type after applying the / operator.
Source§

fn div(self, rhs: StdDuration) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<Duration> for Duration

Source§

type Output = f64

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Duration) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<f32> for Duration

Source§

type Output = Duration

The resulting type after applying the / operator.
Source§

fn div(self, rhs: f32) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<f64> for Duration

Source§

type Output = Duration

The resulting type after applying the / operator.
Source§

fn div(self, rhs: f64) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<i16> for Duration

Source§

type Output = Duration

The resulting type after applying the / operator.
Source§

fn div(self, rhs: i16) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<i32> for Duration

Source§

type Output = Duration

The resulting type after applying the / operator.
Source§

fn div(self, rhs: i32) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<i8> for Duration

Source§

type Output = Duration

The resulting type after applying the / operator.
Source§

fn div(self, rhs: i8) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<u16> for Duration

Source§

type Output = Duration

The resulting type after applying the / operator.
Source§

fn div(self, rhs: u16) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<u32> for Duration

Source§

type Output = Duration

The resulting type after applying the / operator.
Source§

fn div(self, rhs: u32) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<u8> for Duration

Source§

type Output = Duration

The resulting type after applying the / operator.
Source§

fn div(self, rhs: u8) -> Self::Output

Performs the / operation. Read more
Source§

impl Div for Duration

Source§

type Output = f64

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Self) -> Self::Output

Performs the / operation. Read more
Source§

impl DivAssign<f32> for Duration

Source§

fn div_assign(&mut self, rhs: f32)

Performs the /= operation. Read more
Source§

impl DivAssign<f64> for Duration

Source§

fn div_assign(&mut self, rhs: f64)

Performs the /= operation. Read more
Source§

impl DivAssign<i16> for Duration

Source§

fn div_assign(&mut self, rhs: i16)

Performs the /= operation. Read more
Source§

impl DivAssign<i32> for Duration

Source§

fn div_assign(&mut self, rhs: i32)

Performs the /= operation. Read more
Source§

impl DivAssign<i8> for Duration

Source§

fn div_assign(&mut self, rhs: i8)

Performs the /= operation. Read more
Source§

impl DivAssign<u16> for Duration

Source§

fn div_assign(&mut self, rhs: u16)

Performs the /= operation. Read more
Source§

impl DivAssign<u32> for Duration

Source§

fn div_assign(&mut self, rhs: u32)

Performs the /= operation. Read more
Source§

impl DivAssign<u8> for Duration

Source§

fn div_assign(&mut self, rhs: u8)

Performs the /= operation. Read more
Source§

impl Hash for Duration

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Mul<Duration> for f32

Source§

type Output = Duration

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Duration) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<Duration> for f64

Source§

type Output = Duration

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Duration) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<Duration> for i16

Source§

type Output = Duration

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Duration) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<Duration> for i32

Source§

type Output = Duration

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Duration) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<Duration> for i8

Source§

type Output = Duration

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Duration) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<Duration> for u16

Source§

type Output = Duration

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Duration) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<Duration> for u32

Source§

type Output = Duration

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Duration) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<Duration> for u8

Source§

type Output = Duration

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Duration) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<f32> for Duration

Source§

type Output = Duration

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: f32) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<f64> for Duration

Source§

type Output = Duration

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: f64) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<i16> for Duration

Source§

type Output = Duration

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: i16) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<i32> for Duration

Source§

type Output = Duration

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: i32) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<i8> for Duration

Source§

type Output = Duration

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: i8) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<u16> for Duration

Source§

type Output = Duration

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: u16) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<u32> for Duration

Source§

type Output = Duration

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: u32) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<u8> for Duration

Source§

type Output = Duration

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: u8) -> Self::Output

Performs the * operation. Read more
Source§

impl MulAssign<f32> for Duration

Source§

fn mul_assign(&mut self, rhs: f32)

Performs the *= operation. Read more
Source§

impl MulAssign<f64> for Duration

Source§

fn mul_assign(&mut self, rhs: f64)

Performs the *= operation. Read more
Source§

impl MulAssign<i16> for Duration

Source§

fn mul_assign(&mut self, rhs: i16)

Performs the *= operation. Read more
Source§

impl MulAssign<i32> for Duration

Source§

fn mul_assign(&mut self, rhs: i32)

Performs the *= operation. Read more
Source§

impl MulAssign<i8> for Duration

Source§

fn mul_assign(&mut self, rhs: i8)

Performs the *= operation. Read more
Source§

impl MulAssign<u16> for Duration

Source§

fn mul_assign(&mut self, rhs: u16)

Performs the *= operation. Read more
Source§

impl MulAssign<u32> for Duration

Source§

fn mul_assign(&mut self, rhs: u32)

Performs the *= operation. Read more
Source§

impl MulAssign<u8> for Duration

Source§

fn mul_assign(&mut self, rhs: u8)

Performs the *= operation. Read more
Source§

impl Neg for Duration

Source§

type Output = Duration

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl Ord for Duration

Source§

fn cmp(&self, other: &Duration) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq<Duration> for Duration

Source§

fn eq(&self, rhs: &StdDuration) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Duration> for Duration

Source§

fn eq(&self, rhs: &Duration) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq for Duration

Source§

fn eq(&self, other: &Duration) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd<Duration> for Duration

Source§

fn partial_cmp(&self, rhs: &StdDuration) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<Duration> for Duration

Source§

fn partial_cmp(&self, rhs: &Duration) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd for Duration

Source§

fn partial_cmp(&self, other: &Duration) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Sub<Duration> for Date

Source§

fn sub(self, duration: Duration) -> Self::Output

§Panics

This may panic if an overflow occurs.

Source§

type Output = Date

The resulting type after applying the - operator.
Source§

impl Sub<Duration> for Duration

Source§

fn sub(self, rhs: StdDuration) -> Self::Output

§Panics

This may panic if an overflow occurs.

Source§

type Output = Duration

The resulting type after applying the - operator.
Source§

impl Sub<Duration> for Duration

Source§

fn sub(self, rhs: Duration) -> Self::Output

§Panics

This may panic if an overflow occurs.

Source§

type Output = Duration

The resulting type after applying the - operator.
Source§

impl Sub<Duration> for Instant

Source§

type Output = Instant

The resulting type after applying the - operator.
Source§

fn sub(self, duration: Duration) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<Duration> for OffsetDateTime

Source§

fn sub(self, rhs: Duration) -> Self::Output

§Panics

This may panic if an overflow occurs.

Source§

type Output = OffsetDateTime

The resulting type after applying the - operator.
Source§

impl Sub<Duration> for PrimitiveDateTime

Source§

fn sub(self, duration: Duration) -> Self::Output

§Panics

This may panic if an overflow occurs.

Source§

type Output = PrimitiveDateTime

The resulting type after applying the - operator.
Source§

impl Sub<Duration> for SystemTime

Source§

type Output = SystemTime

The resulting type after applying the - operator.
Source§

fn sub(self, duration: Duration) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<Duration> for Time

Source§

fn sub(self, duration: Duration) -> Self::Output

Subtract the sub-day time of the Duration from the Time. Wraps on overflow.

assert_eq!(time!(14:00) - 2.hours(), time!(12:00));
assert_eq!(time!(23:59:59) - (-2).seconds(), time!(0:00:01));
Source§

type Output = Time

The resulting type after applying the - operator.
Source§

impl Sub for Duration

Source§

fn sub(self, rhs: Self) -> Self::Output

§Panics

This may panic if an overflow occurs.

Source§

type Output = Duration

The resulting type after applying the - operator.
Source§

impl SubAssign<Duration> for Date

Source§

fn sub_assign(&mut self, rhs: Duration)

Performs the -= operation. Read more
Source§

impl SubAssign<Duration> for Duration

Source§

fn sub_assign(&mut self, rhs: StdDuration)

Performs the -= operation. Read more
Source§

impl SubAssign<Duration> for Duration

Source§

fn sub_assign(&mut self, rhs: Duration)

§Panics

This may panic if the resulting subtraction can not be represented.

Source§

impl SubAssign<Duration> for Instant

Source§

fn sub_assign(&mut self, rhs: Duration)

Performs the -= operation. Read more
Source§

impl SubAssign<Duration> for OffsetDateTime

Source§

fn sub_assign(&mut self, rhs: Duration)

§Panics

This may panic if an overflow occurs.

Source§

impl SubAssign<Duration> for PrimitiveDateTime

Source§

fn sub_assign(&mut self, duration: Duration)

§Panics

This may panic if an overflow occurs.

Source§

impl SubAssign<Duration> for SystemTime

Source§

fn sub_assign(&mut self, rhs: Duration)

Performs the -= operation. Read more
Source§

impl SubAssign<Duration> for Time

Source§

fn sub_assign(&mut self, rhs: Duration)

Performs the -= operation. Read more
Source§

impl SubAssign for Duration

Source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
Source§

impl<'a> Sum<&'a Duration> for Duration

Source§

fn sum<I: Iterator<Item = &'a Self>>(iter: I) -> Self

Takes an iterator and generates Self from the elements by “summing up” the items.
Source§

impl Sum for Duration

Source§

fn sum<I: Iterator<Item = Self>>(iter: I) -> Self

Takes an iterator and generates Self from the elements by “summing up” the items.
Source§

impl TryFrom<Duration> for Duration

Source§

type Error = ConversionRange

The type returned in the event of a conversion error.
Source§

fn try_from(original: StdDuration) -> Result<Self, ConversionRange>

Performs the conversion.
Source§

impl TryFrom<Duration> for Duration

Source§

type Error = ConversionRange

The type returned in the event of a conversion error.
Source§

fn try_from(duration: Duration) -> Result<Self, ConversionRange>

Performs the conversion.
Source§

impl Copy for Duration

Source§

impl Eq for Duration

Source§

impl StructuralPartialEq for Duration

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.