pub struct Year(/* private fields */);Expand description
A year a work was published or was retrieved in, 1 or later.
A newtype for the same reason Day is one, and it was missing for the
same reason Day’s bound nearly was: a bare i32 let 0 and -1 through
serde, and the formatter rendered them as (0) and (-1, January 2) —
strings that are not dates, printed with a date’s authority, in a module
whose subject is not doing that.
Year zero is not a year in the numbering APA’s readers use, and a negative
year is BCE, which APA writes as 400 B.C.E. and not as -400. Rendering
either as a plain number states something false about the work, so neither
is constructible. BCE dates are not modelled at all: the alternative is an
era field, and half an era model is worse than none.
There is deliberately no upper bound. A year in the future is either a forthcoming work — a legitimate thing to record — or a typo, and no type can separate those without a clock. This crate has no clock and will not acquire one: a record that rendered differently next year would not be reproducible, which is a harder rule here than tidiness about typos.
Implementations§
Trait Implementations§
impl Copy for Year
Source§impl<'de> Deserialize<'de> for Year
impl<'de> Deserialize<'de> for Year
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 Year
Source§impl Ord for Year
impl Ord for Year
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 PartialOrd for Year
impl PartialOrd for Year
impl StructuralPartialEq for Year
Auto Trait Implementations§
impl Freeze for Year
impl RefUnwindSafe for Year
impl Send for Year
impl Sync for Year
impl Unpin for Year
impl UnsafeUnpin for Year
impl UnwindSafe for Year
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.