pub struct Duration {
pub years: i64,
pub months: i64,
pub weeks: i64,
pub days: i64,
pub hours: i64,
pub minutes: i64,
pub seconds: i64,
pub milliseconds: i64,
}Expand description
A duration: the eight units the reference’s duration carries, every one present and zero unless set. A unit may be negative (the difference of two dates can be). Two durations are equal when every unit is.
Its text, the form Display writes, is the duration-literal grammar:
the units largest first, each followed by its suffix (y, mo, w,
d, h, m, s, ms), a zero unit left out, and 0s when every
unit is zero. A negative unit is written with its minus sign.
use predicator_rs::Duration;
let duration = Duration { weeks: 2, days: 3, ..Duration::default() };
assert_eq!(duration.to_string(), "2w3d");
assert_eq!(Duration::default().to_string(), "0s");
assert_eq!(Duration { days: -3, ..Duration::default() }.to_string(), "-3d");Fields§
§years: i64Years.
months: i64Months.
weeks: i64Weeks.
days: i64Days.
hours: i64Hours.
minutes: i64Minutes.
seconds: i64Seconds.
milliseconds: i64Milliseconds.
Trait Implementations§
impl Copy for Duration
Source§impl<'de> Deserialize<'de> for Duration
impl<'de> Deserialize<'de> for Duration
Source§fn deserialize<D: Deserializer<'de>>(
deserializer: D,
) -> Result<Duration, D::Error>
fn deserialize<D: Deserializer<'de>>( deserializer: D, ) -> Result<Duration, D::Error>
Reads the unit map: the seven units other than milliseconds
always, milliseconds when present, each an integer, nothing else.
impl Eq for Duration
impl StructuralPartialEq for Duration
Auto Trait Implementations§
impl Forget for Duration
impl Freeze for Duration
impl Move for Duration
impl RefUnwindSafe for Duration
impl Send for Duration
impl Sync for Duration
impl Unpin for Duration
impl UnsafeUnpin for Duration
impl UnwindSafe for Duration
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more