Enum Weekday

#[repr(u8)]
pub enum Weekday

A representation for the day of the week.

Variants

Monday = 1
Tuesday = 2
Wednesday = 3
Thursday = 4
Friday = 5
Saturday = 6
Sunday = 7

Implementations

impl Weekday

const fn from_monday_zero_offset(offset: i8) -> Result<Weekday, RangeError>

Convert a 0-offset to a Weekday. Monday corresponds to offset 0 and Sunday corresponds to offset 6.

const fn from_monday_one_offset(offset: i8) -> Result<Weekday, RangeError>

Convert a 1-offset to a Weekday. Monday corresponds to offset 1 and Sunday corresponds to offset 7.

const fn from_sunday_zero_offset(offset: i8) -> Result<Weekday, RangeError>

Convert a 0-offset to a Weekday. Sunday corresponds to offset 0 and Saturday corresponds to offset 6.

const fn from_sunday_one_offset(offset: i8) -> Result<Weekday, RangeError>

Convert a 1-offset to a Weekday. Sunday corresponds to offset 1 and Saturday corresponds to offset 7.

const fn to_monday_zero_offset(self) -> i8

Returns the weekday as a 0-offset. Monday corresponds to offset 0 and Sunday corresponds to offset 6.

const fn to_monday_one_offset(self) -> i8

Returns the weekday as a 1-offset. Monday corresponds to offset 1 and Sunday corresponds to offset 7.

const fn to_sunday_zero_offset(self) -> i8

Returns the weekday as a 0-offset. Sunday corresponds to offset 0 and Saturday corresponds to offset 6.

const fn to_sunday_one_offset(self) -> i8

Returns the weekday as a 1-offset. Sunday corresponds to offset 1 and Saturday corresponds to offset 7.

const fn wrapping_add(self, days: i64) -> Weekday

Add the given number of days to this weekday, using wrapping arithmetic, and return the resulting weekday.

Adding a multiple of 7 (including 0) is guaranteed to produce the same weekday as this one.

const fn wrapping_sub(self, days: i64) -> Weekday

Subtract the given number of days from this weekday, using wrapping arithmetic, and return the resulting weekday.

Subtracting a multiple of 7 (including 0) is guaranteed to produce the same weekday as this one.

const fn next(self) -> Weekday

Returns the next weekday, wrapping around at the end of week to the beginning of the week.

This is a convenience routing for calling Weekday::wrapping_add with a value of 1.

const fn previous(self) -> Weekday

Returns the previous weekday, wrapping around at the beginning of week to the end of the week.

This is a convenience routing for calling Weekday::wrapping_sub with a value of 1.

const fn since(self, other: Weekday) -> i8

Returns the number of days from other to this weekday.

Adding the returned number of days to other is guaranteed to sum to this weekday. The number of days returned is guaranteed to be in the range 0..=6.

const fn until(self, other: Weekday) -> i8

Returns the number of days until other from this weekday.

Adding the returned number of days to this weekday is guaranteed to sum to other weekday. The number of days returned is guaranteed to be in the range 0..=6.

const fn cycle_forward(self) -> WeekdaysForward

Starting with this weekday, this returns an unending iterator that cycles forward through the days of the week.

const fn cycle_reverse(self) -> WeekdaysReverse

Starting with this weekday, this returns an unending iterator that cycles backward through the days of the week.

Trait Implementations

impl Clone for Weekday

fn clone(&self) -> Weekday

impl Copy for Weekday

impl Debug for Weekday

fn fmt(&self, f: &mut Formatter<'_>) -> Result

impl Eq for Weekday

impl Hash for Weekday

fn hash<__H: Hasher>(&self, state: &mut __H)

impl PartialEq for Weekday

fn eq(&self, other: &Weekday) -> bool

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 UnsafeUnpin for Weekday

impl UnwindSafe for Weekday

Blanket Implementations

impl<T> Any for Weekday where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for Weekday where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for Weekday where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> CloneToUninit for Weekday where T: Clone,

unsafe fn clone_to_uninit(&self, dest: *mut u8)

impl<T> From<T> for Weekday

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for Weekday where T: Clone,

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

impl<T, U> Into<U> for Weekday where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom<U> for Weekday where U: Into<T>,

type Error = Infallible;
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto<U> for Weekday where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>