pub enum Weekday {
Monday,
Tuesday,
Wednesday,
Thursday,
Friday,
Saturday,
Sunday,
}
Expand description
Days of the week.
As order is dependent on context (Sunday could be either two days after or five days before
Friday), this type does not implement PartialOrd
or Ord
.
Variants§
Implementations§
§impl Weekday
impl Weekday
pub const fn previous(self) -> Weekday
pub const fn previous(self) -> Weekday
Get the previous weekday.
assert_eq!(Weekday::Tuesday.previous(), Weekday::Monday);
pub const fn next(self) -> Weekday
pub const fn next(self) -> Weekday
Get the next weekday.
assert_eq!(Weekday::Monday.next(), Weekday::Tuesday);
pub const fn nth_next(self, n: u8) -> Weekday
pub const fn nth_next(self, n: u8) -> Weekday
Get n-th next day.
assert_eq!(Weekday::Monday.nth_next(1), Weekday::Tuesday);
assert_eq!(Weekday::Sunday.nth_next(10), Weekday::Wednesday);
pub const fn nth_prev(self, n: u8) -> Weekday
pub const fn nth_prev(self, n: u8) -> Weekday
Get n-th previous day.
assert_eq!(Weekday::Monday.nth_prev(1), Weekday::Sunday);
assert_eq!(Weekday::Sunday.nth_prev(10), Weekday::Thursday);
pub const fn number_from_monday(self) -> u8
pub const fn number_from_monday(self) -> u8
Get the one-indexed number of days from Monday.
assert_eq!(Weekday::Monday.number_from_monday(), 1);
pub const fn number_from_sunday(self) -> u8
pub const fn number_from_sunday(self) -> u8
Get the one-indexed number of days from Sunday.
assert_eq!(Weekday::Monday.number_from_sunday(), 2);
pub const fn number_days_from_monday(self) -> u8
pub const fn number_days_from_monday(self) -> u8
Get the zero-indexed number of days from Monday.
assert_eq!(Weekday::Monday.number_days_from_monday(), 0);
pub const fn number_days_from_sunday(self) -> u8
pub const fn number_days_from_sunday(self) -> u8
Get the zero-indexed number of days from Sunday.
assert_eq!(Weekday::Monday.number_days_from_sunday(), 1);
Trait Implementations§
§impl<'a> Deserialize<'a> for Weekday
impl<'a> Deserialize<'a> for Weekday
§fn deserialize<D>(
deserializer: D,
) -> Result<Weekday, <D as Deserializer<'a>>::Error>where
D: Deserializer<'a>,
fn deserialize<D>(
deserializer: D,
) -> Result<Weekday, <D as Deserializer<'a>>::Error>where
D: Deserializer<'a>,
Deserialize this value from the given Serde deserializer. Read more
§impl Serialize for Weekday
impl Serialize for Weekday
§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
§impl SmartDisplay for Weekday
impl SmartDisplay for Weekday
§fn metadata(&self, _: FormatterOptions) -> Metadata<'_, Weekday>
fn metadata(&self, _: FormatterOptions) -> Metadata<'_, Weekday>
Compute any information needed to format the value. This must, at a minimum, determine the
width of the value before any padding is added by the formatter. Read more
impl Copy for Weekday
impl Eq for Weekday
impl StructuralPartialEq for Weekday
Auto Trait Implementations§
impl Freeze for Weekday
impl RefUnwindSafe for Weekday
impl Send for Weekday
impl Sync for Weekday
impl Unpin for Weekday
impl UnwindSafe for Weekday
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.