pub struct Year(pub u16);Expand description
Any year from 0 to 65,535
Tuple Fields§
§0: u16Implementations§
source§impl Year
impl Year
sourcepub const fn is_leap_year(self) -> bool
pub const fn is_leap_year(self) -> bool
assert!(!Year(2019).is_leap_year());
assert!(Year(2020).is_leap_year());
assert!(!Year(2023).is_leap_year());
assert!(Year(2024).is_leap_year());sourcepub const fn days_in_year(self) -> DaysInYear
pub const fn days_in_year(self) -> DaysInYear
// Non-leap year.
assert_eq!(Year(2019).days_in_year(), 365);
// Leap year.
assert_eq!(Year(2020).days_in_year(), 366);sourcepub const fn days_in_month(self, month: Month) -> Day
pub const fn days_in_month(self, month: Month) -> Day
assert_eq!(
Year(2019).days_in_month(Month::January),
Day::ThirtyFirst,
);
assert_eq!(
Year(2019).days_in_month(Month::April),
Day::Thirtieth,
);
assert_eq!(
Year(2019).days_in_month(Month::February),
Day::TwentyEighth,
);
// Leap Year
assert_eq!(
Year(2020).days_in_month(Month::February),
Day::TwentyNinth,
);Methods from Deref<Target = u16>§
pub const MIN: u16 = 0u16
pub const MAX: u16 = 65_535u16
pub const BITS: u32 = 16u32
Trait Implementations§
source§impl AddAssign for Year
impl AddAssign for Year
source§fn add_assign(&mut self, rhs: Year)
fn add_assign(&mut self, rhs: Year)
Performs the
+= operation. Read moresource§impl<'__de> BorrowDecode<'__de> for Year
impl<'__de> BorrowDecode<'__de> for Year
source§fn borrow_decode<__D: BorrowDecoder<'__de>>(
decoder: &mut __D
) -> Result<Self, DecodeError>
fn borrow_decode<__D: BorrowDecoder<'__de>>( decoder: &mut __D ) -> Result<Self, DecodeError>
Attempt to decode this type with the given BorrowDecode.
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>,
Deserialize this value from the given Serde deserializer. Read more
source§impl<__RhsT> MulAssign<__RhsT> for Year
impl<__RhsT> MulAssign<__RhsT> for Year
source§fn mul_assign(&mut self, rhs: __RhsT)
fn mul_assign(&mut self, rhs: __RhsT)
Performs the
*= operation. Read moresource§impl Ord for Year
impl Ord for Year
source§impl PartialEq<i128> for Year
impl PartialEq<i128> for Year
source§impl PartialEq<isize> for Year
impl PartialEq<isize> for Year
source§impl PartialEq<u128> for Year
impl PartialEq<u128> for Year
source§impl PartialEq<usize> for Year
impl PartialEq<usize> for Year
source§impl PartialEq for Year
impl PartialEq for Year
source§impl PartialOrd for Year
impl PartialOrd for Year
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self and other) and is used by the <=
operator. Read moreimpl Copy for Year
impl Eq for Year
impl StructuralEq for Year
impl StructuralPartialEq for Year
Auto Trait Implementations§
impl RefUnwindSafe for Year
impl Send for Year
impl Sync for Year
impl Unpin 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
Mutably borrows from an owned value. Read more