pub enum PublicationDate {
Year(Year),
YearMonth {
year: Year,
month: Month,
},
Full {
year: Year,
month: Month,
day: Day,
},
}Expand description
When a work was published.
An enum rather than a struct of Options so that a day without a month is
unrepresentable. Note that this models the precision of a known date, not
whether one is known at all — that is Attested’s job, and a
Reference::published of Attested::AbsentFromWork is what becomes
n.d..
Deliberately not #[non_exhaustive]. APA recognises date shapes this does
not carry yet — a season, a range — so the set may well grow. That is the
reason for closing it: when it grows, every renderer stops compiling until
it says how the new shape is printed, where a wildcard arm would print it as
something else. Rendering a date as a date it is not is the failure this
whole module is about.
Variants§
Year(Year)
The year alone — the commonest case, and all APA requires of most works.
YearMonth
A year and a month.
Full
A full calendar date.
Implementations§
Source§impl PublicationDate
impl PublicationDate
Sourcepub fn names_a_day_that_exists(self) -> bool
pub fn names_a_day_that_exists(self) -> bool
Whether this names a day that exists.
Always true for the Year and YearMonth precisions, which cannot name
a day at all. For Full it is the question Day cannot answer on its
own: Day::new(31) is valid, and February 31 is not.
A method rather than a constructor because making the state unrepresentable means giving this enum an opaque shape — a smart constructor and private fields on a public enum — which is a wider change than the defect warrants. So the formatter refuses instead, which is the module’s other setting and the one it uses wherever a record can be written but not cited.
Trait Implementations§
Source§impl Clone for PublicationDate
impl Clone for PublicationDate
impl Copy for PublicationDate
Source§impl Debug for PublicationDate
impl Debug for PublicationDate
Source§impl<'de> Deserialize<'de> for PublicationDate
impl<'de> Deserialize<'de> for PublicationDate
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for PublicationDate
Source§impl Ord for PublicationDate
impl Ord for PublicationDate
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for PublicationDate
impl PartialEq for PublicationDate
Source§impl PartialOrd for PublicationDate
impl PartialOrd for PublicationDate
Source§impl Serialize for PublicationDate
impl Serialize for PublicationDate
impl StructuralPartialEq for PublicationDate
Auto Trait Implementations§
impl Freeze for PublicationDate
impl RefUnwindSafe for PublicationDate
impl Send for PublicationDate
impl Sync for PublicationDate
impl Unpin for PublicationDate
impl UnsafeUnpin for PublicationDate
impl UnwindSafe for PublicationDate
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.