pub struct ReviewDate {
pub year: u16,
pub month: u8,
pub day: u8,
}Expand description
A human review date (YYYY-MM-DD).
Hand-written by design: it asserts “a person verified this entry as of
this date”, which no tool can derive. (Contrast modified, which is stamped
automatically — a human would forget to bump it and the field would lie.)
Const-validated and ordered, so reviewed <= today is checkable.
const R: ReviewDate = ReviewDate::parse("2026-07-21");
assert_eq!(R.to_string(), "2026-07-21");Fields§
§year: u16Four-digit year.
month: u8Month, 1..=12.
day: u8Day, 1..=31.
Implementations§
Source§impl ReviewDate
impl ReviewDate
Sourcepub const fn parse(s: &str) -> ReviewDate
pub const fn parse(s: &str) -> ReviewDate
Parse YYYY-MM-DD in a const context.
§Panics
At compile time for a wrong length, missing dashes, non-digits, or a month/day outside range.
Sourcepub fn try_parse(s: &str) -> Option<ReviewDate>
pub fn try_parse(s: &str) -> Option<ReviewDate>
Fallible runtime parse.
Sourcepub fn next_day(self) -> ReviewDate
pub fn next_day(self) -> ReviewDate
The following day. Used to allow one day of slack when comparing a hand-written local date against a UTC clock.
Sourcepub fn today() -> ReviewDate
pub fn today() -> ReviewDate
Today in UTC, from the system clock. Used to reject future review dates.
Trait Implementations§
Source§impl Clone for ReviewDate
impl Clone for ReviewDate
Source§fn clone(&self) -> ReviewDate
fn clone(&self) -> ReviewDate
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for ReviewDate
Source§impl Debug for ReviewDate
impl Debug for ReviewDate
Source§impl Display for ReviewDate
impl Display for ReviewDate
impl Eq for ReviewDate
Source§impl Hash for ReviewDate
impl Hash for ReviewDate
Source§impl Ord for ReviewDate
impl Ord for ReviewDate
Source§fn cmp(&self, other: &ReviewDate) -> Ordering
fn cmp(&self, other: &ReviewDate) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialEq for ReviewDate
impl PartialEq for ReviewDate
Source§impl PartialOrd for ReviewDate
impl PartialOrd for ReviewDate
impl StructuralPartialEq for ReviewDate
Auto Trait Implementations§
impl Freeze for ReviewDate
impl RefUnwindSafe for ReviewDate
impl Send for ReviewDate
impl Sync for ReviewDate
impl Unpin for ReviewDate
impl UnsafeUnpin for ReviewDate
impl UnwindSafe for ReviewDate
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