Enum Weekday
pub enum Weekday
The day of week.
The order of the days of week depends on the context.
(This is why this type does not implement PartialOrd or Ord traits.)
One should prefer *_from_monday or *_from_sunday methods to get the correct result.
Example
use Weekday;
let monday = "Monday"..unwrap;
assert_eq!;
let sunday = try_from.unwrap;
assert_eq!;
assert_eq!; // starts counting with Monday = 0
assert_eq!; // starts counting with Monday = 1
assert_eq!; // starts counting with Sunday = 0
assert_eq!; // starts counting with Sunday = 1
assert_eq!;
assert_eq!;
Variants
-
Mon = 0 Monday.
-
Tue = 1 Tuesday.
-
Wed = 2 Wednesday.
-
Thu = 3 Thursday.
-
Fri = 4 Friday.
-
Sat = 5 Saturday.
-
Sun = 6 Sunday.
Implementations
impl Weekday
const fn succ(&self) -> WeekdayThe next day in the week.
w:MonTueWedThuFriSatSunw.succ():TueWedThuFriSatSunMonconst fn pred(&self) -> WeekdayThe previous day in the week.
w:MonTueWedThuFriSatSunw.pred():SunMonTueWedThuFriSatconst fn number_from_monday(&self) -> u32Returns a day-of-week number starting from Monday = 1. (ISO 8601 weekday number)
w:MonTueWedThuFriSatSunw.number_from_monday():1 2 3 4 5 6 7 const fn number_from_sunday(&self) -> u32Returns a day-of-week number starting from Sunday = 1.
w:MonTueWedThuFriSatSunw.number_from_sunday():2 3 4 5 6 7 1 const fn num_days_from_monday(&self) -> u32Returns a day-of-week number starting from Monday = 0.
w:MonTueWedThuFriSatSunw.num_days_from_monday():0 1 2 3 4 5 6 Example
#const fn num_days_from_sunday(&self) -> u32Returns a day-of-week number starting from Sunday = 0.
w:MonTueWedThuFriSatSunw.num_days_from_sunday():1 2 3 4 5 6 0 const fn days_since(&self, other: Weekday) -> u32The number of days since the given day.
Examples
use *; assert_eq!; assert_eq!; assert_eq!;
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 Display for Weekday
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl Eq for Weekday
impl FromPrimitive for Weekday
fn from_i64(n: i64) -> Option<Weekday>fn from_u64(n: u64) -> Option<Weekday>
impl FromStr for Weekday
type Err = ParseWeekdayError;fn from_str(s: &str) -> Result<Self, Self::Err>
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
impl TryFrom<u8> for Weekday
type Error = OutOfRange;fn try_from(value: u8) -> Result<Self, Self::Error>
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) -> TReturns the argument unchanged.
impl<T> ToOwned for Weekday
where
T: Clone,
type Owned = T;fn to_owned(&self) -> Tfn clone_into(&self, target: &mut T)
impl<T> ToString for Weekday
where
T: Display + ?Sized,
fn to_string(&self) -> String
impl<T, U> Into<U> for Weekday
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses 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>