Enum Weekday
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 Monday.
-
Tue Tuesday.
-
Wed Wednesday.
-
Thu Thursday.
-
Fri Friday.
-
Sat Saturday.
-
Sun Sunday.
Implementations
impl Weekday
const fn succ(self: &Self) -> WeekdayThe next day in the week.
w:MonTueWedThuFriSatSunw.succ():TueWedThuFriSatSunMonconst fn pred(self: &Self) -> WeekdayThe previous day in the week.
w:MonTueWedThuFriSatSunw.pred():SunMonTueWedThuFriSatconst fn number_from_monday(self: &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: &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: &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: &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: &Self, other: Weekday) -> u32The number of days since the given day.
Examples
use *; assert_eq!; assert_eq!; assert_eq!;
impl Clone for Weekday
fn clone(self: &Self) -> Weekday
impl Copy for Weekday
impl Debug for Weekday
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl Display for Weekday
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl Eq for Weekday
impl Freeze for Weekday
impl FromPrimitive for Weekday
fn from_i64(n: i64) -> Option<Weekday>fn from_u64(n: u64) -> Option<Weekday>
impl FromStr for Weekday
fn from_str(s: &str) -> Result<Self, <Self as >::Err>
impl Hash for Weekday
fn hash<__H: $crate::hash::Hasher>(self: &Self, state: &mut __H)
impl PartialEq for Weekday
fn eq(self: &Self, other: &Weekday) -> bool
impl RefUnwindSafe for Weekday
impl Send for Weekday
impl StructuralPartialEq for Weekday
impl Sync for Weekday
impl TryFrom for Weekday
fn try_from(value: u8) -> Result<Self, <Self as >::Error>
impl Unpin for Weekday
impl UnsafeUnpin for Weekday
impl UnwindSafe for Weekday
impl<T> Any for Weekday
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for Weekday
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for Weekday
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> CloneToUninit for Weekday
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)
impl<T> From for Weekday
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for Weekday
fn to_owned(self: &Self) -> Tfn clone_into(self: &Self, target: &mut T)
impl<T> ToString for Weekday
fn to_string(self: &Self) -> String
impl<T, U> Into for Weekday
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for Weekday
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for Weekday
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>