#[repr(u8)]pub enum Month {
January = 1,
February = 2,
March = 3,
April = 4,
May = 5,
June = 6,
July = 7,
August = 8,
September = 9,
October = 10,
November = 11,
December = 12,
}Expand description
Month in a year
Variants§
January = 1
February = 2
March = 3
April = 4
May = 5
June = 6
July = 7
August = 8
September = 9
October = 10
November = 11
December = 12
Implementations§
source§impl Month
impl Month
sourcepub const ALL: [Month; 12] = _
pub const ALL: [Month; 12] = _
assert_eq!(Month::ALL[0], Month::January);
assert_eq!(Month::ALL[1], Month::February);
assert_eq!(Month::ALL[2], Month::March);
assert_eq!(Month::ALL[3], Month::April);
assert_eq!(Month::ALL[4], Month::May);
assert_eq!(Month::ALL[5], Month::June);
assert_eq!(Month::ALL[6], Month::July);
assert_eq!(Month::ALL[7], Month::August);
assert_eq!(Month::ALL[8], Month::September);
assert_eq!(Month::ALL[9], Month::October);
assert_eq!(Month::ALL[10], Month::November);
assert_eq!(Month::ALL[11], Month::December);sourcepub const fn new(month: u8) -> Self
pub const fn new(month: u8) -> Self
assert_eq!(Month::new(1), Month::January);
assert_eq!(Month::new(2), Month::February);
assert_eq!(Month::new(3), Month::March);
assert_eq!(Month::new(4), Month::April);
assert_eq!(Month::new(5), Month::May);
assert_eq!(Month::new(6), Month::June);
assert_eq!(Month::new(7), Month::July);
assert_eq!(Month::new(8), Month::August);
assert_eq!(Month::new(9), Month::September);
assert_eq!(Month::new(10), Month::October);
assert_eq!(Month::new(11), Month::November);
assert_eq!(Month::new(12), Month::December);ⓘ
Month::new(0);ⓘ
Month::new(13);sourcepub const fn new_saturating(month: u8) -> Self
pub const fn new_saturating(month: u8) -> Self
assert_eq!(Month::new_saturating(1), Month::January);
assert_eq!(Month::new_saturating(2), Month::February);
assert_eq!(Month::new_saturating(3), Month::March);
assert_eq!(Month::new_saturating(4), Month::April);
assert_eq!(Month::new_saturating(5), Month::May);
assert_eq!(Month::new_saturating(6), Month::June);
assert_eq!(Month::new_saturating(7), Month::July);
assert_eq!(Month::new_saturating(8), Month::August);
assert_eq!(Month::new_saturating(9), Month::September);
assert_eq!(Month::new_saturating(10), Month::October);
assert_eq!(Month::new_saturating(11), Month::November);
assert_eq!(Month::new_saturating(12), Month::December);assert_eq!(Month::new_saturating(0), Month::January);assert_eq!(Month::new_saturating(13), Month::December);
assert_eq!(Month::new_saturating(14), Month::December);sourcepub const fn new_wrapping(month: u8) -> Self
pub const fn new_wrapping(month: u8) -> Self
// Wraps to December
assert_eq!(Month::new_wrapping(0), Month::December);
assert_eq!(Month::new_wrapping(1), Month::January);
assert_eq!(Month::new_wrapping(2), Month::February);
assert_eq!(Month::new_wrapping(3), Month::March);
assert_eq!(Month::new_wrapping(4), Month::April);
assert_eq!(Month::new_wrapping(5), Month::May);
assert_eq!(Month::new_wrapping(6), Month::June);
assert_eq!(Month::new_wrapping(7), Month::July);
assert_eq!(Month::new_wrapping(8), Month::August);
assert_eq!(Month::new_wrapping(9), Month::September);
assert_eq!(Month::new_wrapping(10), Month::October);
assert_eq!(Month::new_wrapping(11), Month::November);
assert_eq!(Month::new_wrapping(12), Month::December);
// Wraps to January, February, etc
assert_eq!(Month::new_wrapping(13), Month::January);
assert_eq!(Month::new_wrapping(14), Month::February);
assert_eq!(Month::new_wrapping(15), Month::March);
assert_eq!(Month::new_wrapping(16), Month::April);
assert_eq!(Month::new_wrapping(17), Month::May);
assert_eq!(Month::new_wrapping(18), Month::June);
assert_eq!(Month::new_wrapping(19), Month::July);
assert_eq!(Month::new_wrapping(20), Month::August);
assert_eq!(Month::new_wrapping(21), Month::September);
assert_eq!(Month::new_wrapping(22), Month::October);
assert_eq!(Month::new_wrapping(23), Month::November);
assert_eq!(Month::new_wrapping(24), Month::December);sourcepub const fn next_saturating(self) -> Self
pub const fn next_saturating(self) -> Self
Get the next Self, saturating if we’re at Self::LAST
sourcepub const fn next_wrapping(self) -> Self
pub const fn next_wrapping(self) -> Self
Get the next Self, wrapping if we’re at Self::LAST
sourcepub const fn previous_saturating(self) -> Self
pub const fn previous_saturating(self) -> Self
Get the previous Self, saturating if we’re at Self::FIRST
sourcepub const fn previous_wrapping(self) -> Self
pub const fn previous_wrapping(self) -> Self
Get the previous Self, wrapping if we’re at Self::FIRST
sourcepub const fn add_saturating(self, rhs: u8) -> Self
pub const fn add_saturating(self, rhs: u8) -> Self
Add onto Self, saturating if we’re at Self::LAST
sourcepub const fn sub_saturating(self, rhs: u8) -> Self
pub const fn sub_saturating(self, rhs: u8) -> Self
Subtract from Self, saturating if we’re at Self::FIRST
sourcepub const fn add_wrapping(self, rhs: u8) -> Self
pub const fn add_wrapping(self, rhs: u8) -> Self
Add onto Self, wrapping if we’re at Self::LAST
sourcepub const fn sub_wrapping(self, rhs: u8) -> Self
pub const fn sub_wrapping(self, rhs: u8) -> Self
Subtract from Self, wrapping if we’re at Self::FIRST
sourcepub const fn as_str(self) -> &'static str
pub const fn as_str(self) -> &'static str
assert_eq!(Month::January.as_str(), "January");
assert_eq!(Month::February.as_str(), "February");
assert_eq!(Month::March.as_str(), "March");
assert_eq!(Month::April.as_str(), "April");
assert_eq!(Month::May.as_str(), "May");
assert_eq!(Month::June.as_str(), "June");
assert_eq!(Month::July.as_str(), "July");
assert_eq!(Month::August.as_str(), "August");
assert_eq!(Month::September.as_str(), "September");
assert_eq!(Month::October.as_str(), "October");
assert_eq!(Month::November.as_str(), "November");
assert_eq!(Month::December.as_str(), "December");sourcepub const fn as_str_lower(self) -> &'static str
pub const fn as_str_lower(self) -> &'static str
assert_eq!(Month::January.as_str_lower(), "january");
assert_eq!(Month::February.as_str_lower(), "february");
assert_eq!(Month::March.as_str_lower(), "march");
assert_eq!(Month::April.as_str_lower(), "april");
assert_eq!(Month::May.as_str_lower(), "may");
assert_eq!(Month::June.as_str_lower(), "june");
assert_eq!(Month::July.as_str_lower(), "july");
assert_eq!(Month::August.as_str_lower(), "august");
assert_eq!(Month::September.as_str_lower(), "september");
assert_eq!(Month::October.as_str_lower(), "october");
assert_eq!(Month::November.as_str_lower(), "november");
assert_eq!(Month::December.as_str_lower(), "december");sourcepub const fn as_str_upper(self) -> &'static str
pub const fn as_str_upper(self) -> &'static str
assert_eq!(Month::January.as_str_upper(), "JANUARY");
assert_eq!(Month::February.as_str_upper(), "FEBRUARY");
assert_eq!(Month::March.as_str_upper(), "MARCH");
assert_eq!(Month::April.as_str_upper(), "APRIL");
assert_eq!(Month::May.as_str_upper(), "MAY");
assert_eq!(Month::June.as_str_upper(), "JUNE");
assert_eq!(Month::July.as_str_upper(), "JULY");
assert_eq!(Month::August.as_str_upper(), "AUGUST");
assert_eq!(Month::September.as_str_upper(), "SEPTEMBER");
assert_eq!(Month::October.as_str_upper(), "OCTOBER");
assert_eq!(Month::November.as_str_upper(), "NOVEMBER");
assert_eq!(Month::December.as_str_upper(), "DECEMBER");sourcepub const fn as_str_short(self) -> &'static str
pub const fn as_str_short(self) -> &'static str
assert_eq!(Month::January.as_str_short(), "Jan");
assert_eq!(Month::February.as_str_short(), "Feb");
assert_eq!(Month::March.as_str_short(), "Mar");
assert_eq!(Month::April.as_str_short(), "Apr");
assert_eq!(Month::May.as_str_short(), "May");
assert_eq!(Month::June.as_str_short(), "Jun");
assert_eq!(Month::July.as_str_short(), "Jul");
assert_eq!(Month::August.as_str_short(), "Aug");
assert_eq!(Month::September.as_str_short(), "Sep");
assert_eq!(Month::October.as_str_short(), "Oct");
assert_eq!(Month::November.as_str_short(), "Nov");
assert_eq!(Month::December.as_str_short(), "Dec");sourcepub const fn as_str_short_lower(self) -> &'static str
pub const fn as_str_short_lower(self) -> &'static str
assert_eq!(Month::January.as_str_short_lower(), "jan");
assert_eq!(Month::February.as_str_short_lower(), "feb");
assert_eq!(Month::March.as_str_short_lower(), "mar");
assert_eq!(Month::April.as_str_short_lower(), "apr");
assert_eq!(Month::May.as_str_short_lower(), "may");
assert_eq!(Month::June.as_str_short_lower(), "jun");
assert_eq!(Month::July.as_str_short_lower(), "jul");
assert_eq!(Month::August.as_str_short_lower(), "aug");
assert_eq!(Month::September.as_str_short_lower(), "sep");
assert_eq!(Month::October.as_str_short_lower(), "oct");
assert_eq!(Month::November.as_str_short_lower(), "nov");
assert_eq!(Month::December.as_str_short_lower(), "dec");sourcepub const fn as_str_short_upper(self) -> &'static str
pub const fn as_str_short_upper(self) -> &'static str
assert_eq!(Month::January.as_str_short_upper(), "JAN");
assert_eq!(Month::February.as_str_short_upper(), "FEB");
assert_eq!(Month::March.as_str_short_upper(), "MAR");
assert_eq!(Month::April.as_str_short_upper(), "APR");
assert_eq!(Month::May.as_str_short_upper(), "MAY");
assert_eq!(Month::June.as_str_short_upper(), "JUN");
assert_eq!(Month::July.as_str_short_upper(), "JUL");
assert_eq!(Month::August.as_str_short_upper(), "AUG");
assert_eq!(Month::September.as_str_short_upper(), "SEP");
assert_eq!(Month::October.as_str_short_upper(), "OCT");
assert_eq!(Month::November.as_str_short_upper(), "NOV");
assert_eq!(Month::December.as_str_short_upper(), "DEC");sourcepub const fn as_str_num(self) -> &'static str
pub const fn as_str_num(self) -> &'static str
assert_eq!(Month::January.as_str_num(), "1");
assert_eq!(Month::February.as_str_num(), "2");
assert_eq!(Month::March.as_str_num(), "3");
assert_eq!(Month::April.as_str_num(), "4");
assert_eq!(Month::May.as_str_num(), "5");
assert_eq!(Month::June.as_str_num(), "6");
assert_eq!(Month::July.as_str_num(), "7");
assert_eq!(Month::August.as_str_num(), "8");
assert_eq!(Month::September.as_str_num(), "9");
assert_eq!(Month::October.as_str_num(), "10");
assert_eq!(Month::November.as_str_num(), "11");
assert_eq!(Month::December.as_str_num(), "12");sourcepub const fn as_str_jp(self) -> &'static str
pub const fn as_str_jp(self) -> &'static str
assert_eq!(Month::January.as_str_jp(), "一月");
assert_eq!(Month::February.as_str_jp(), "二月");
assert_eq!(Month::March.as_str_jp(), "三月");
assert_eq!(Month::April.as_str_jp(), "四月");
assert_eq!(Month::May.as_str_jp(), "五月");
assert_eq!(Month::June.as_str_jp(), "六月");
assert_eq!(Month::July.as_str_jp(), "七月");
assert_eq!(Month::August.as_str_jp(), "八月");
assert_eq!(Month::September.as_str_jp(), "九月");
assert_eq!(Month::October.as_str_jp(), "十月");
assert_eq!(Month::November.as_str_jp(), "十一月");
assert_eq!(Month::December.as_str_jp(), "十二月");sourcepub const fn from_str(s: &str) -> Option<Self>
pub const fn from_str(s: &str) -> Option<Self>
Create a [Weekday] by parsing a &str
A valid input string can either be the first 3 letters of the day (returned from [Weekday::as_str_short])
or the full weekday (returned from [Weekday::as_str]).
These cases are covered:
lowercaseUPPERCASE
For example:
assert_eq!(Weekday::from_str("SUN").unwrap(), Weekday::Sunday);
assert_eq!(Weekday::from_str("Sun").unwrap(), Weekday::Sunday);
assert_eq!(Weekday::from_str("sun").unwrap(), Weekday::Sunday);
assert_eq!(Weekday::from_str("SUNDAY").unwrap(), Weekday::Sunday);
assert_eq!(Weekday::from_str("Sunday").unwrap(), Weekday::Sunday);
assert_eq!(Weekday::from_str("sunday").unwrap(), Weekday::Sunday);None
If:
s.len() > 9- The string could not be parsed
then this function will return
None.
(and all case-combinations).
Examples
assert_eq!(Month::from_str("1").unwrap(), Month::January);
assert_eq!(Month::from_str("January").unwrap(), Month::January);
assert_eq!(Month::from_str("january").unwrap(), Month::January);
assert_eq!(Month::from_str("JANUARY").unwrap(), Month::January);
assert_eq!(Month::from_str("Jan").unwrap(), Month::January);
assert_eq!(Month::from_str("jan").unwrap(), Month::January);
assert_eq!(Month::from_str("JAN").unwrap(), Month::January);
assert_eq!(Month::from_str("2").unwrap(), Month::February);
assert_eq!(Month::from_str("February").unwrap(), Month::February);
assert_eq!(Month::from_str("february").unwrap(), Month::February);
assert_eq!(Month::from_str("FEBRUARY").unwrap(), Month::February);
assert_eq!(Month::from_str("Feb").unwrap(), Month::February);
assert_eq!(Month::from_str("feb").unwrap(), Month::February);
assert_eq!(Month::from_str("FEB").unwrap(), Month::February);
assert_eq!(Month::from_str("3").unwrap(), Month::March);
assert_eq!(Month::from_str("March").unwrap(), Month::March);
assert_eq!(Month::from_str("march").unwrap(), Month::March);
assert_eq!(Month::from_str("MARCH").unwrap(), Month::March);
assert_eq!(Month::from_str("Mar").unwrap(), Month::March);
assert_eq!(Month::from_str("mar").unwrap(), Month::March);
assert_eq!(Month::from_str("MAR").unwrap(), Month::March);
assert_eq!(Month::from_str("4").unwrap(), Month::April);
assert_eq!(Month::from_str("April").unwrap(), Month::April);
assert_eq!(Month::from_str("april").unwrap(), Month::April);
assert_eq!(Month::from_str("APRIL").unwrap(), Month::April);
assert_eq!(Month::from_str("Apr").unwrap(), Month::April);
assert_eq!(Month::from_str("apr").unwrap(), Month::April);
assert_eq!(Month::from_str("APR").unwrap(), Month::April);
assert_eq!(Month::from_str("5").unwrap(), Month::May);
assert_eq!(Month::from_str("May").unwrap(), Month::May);
assert_eq!(Month::from_str("may").unwrap(), Month::May);
assert_eq!(Month::from_str("MAY").unwrap(), Month::May);
assert_eq!(Month::from_str("6").unwrap(), Month::June);
assert_eq!(Month::from_str("June").unwrap(), Month::June);
assert_eq!(Month::from_str("june").unwrap(), Month::June);
assert_eq!(Month::from_str("JUNE").unwrap(), Month::June);
assert_eq!(Month::from_str("Jun").unwrap(), Month::June);
assert_eq!(Month::from_str("jun").unwrap(), Month::June);
assert_eq!(Month::from_str("JUN").unwrap(), Month::June);
assert_eq!(Month::from_str("7").unwrap(), Month::July);
assert_eq!(Month::from_str("July").unwrap(), Month::July);
assert_eq!(Month::from_str("july").unwrap(), Month::July);
assert_eq!(Month::from_str("JULY").unwrap(), Month::July);
assert_eq!(Month::from_str("Jul").unwrap(), Month::July);
assert_eq!(Month::from_str("jul").unwrap(), Month::July);
assert_eq!(Month::from_str("JUL").unwrap(), Month::July);
assert_eq!(Month::from_str("8").unwrap(), Month::August);
assert_eq!(Month::from_str("August").unwrap(), Month::August);
assert_eq!(Month::from_str("august").unwrap(), Month::August);
assert_eq!(Month::from_str("AUGUST").unwrap(), Month::August);
assert_eq!(Month::from_str("Aug").unwrap(), Month::August);
assert_eq!(Month::from_str("aug").unwrap(), Month::August);
assert_eq!(Month::from_str("AUG").unwrap(), Month::August);
assert_eq!(Month::from_str("9").unwrap(), Month::September);
assert_eq!(Month::from_str("September").unwrap(), Month::September);
assert_eq!(Month::from_str("september").unwrap(), Month::September);
assert_eq!(Month::from_str("SEPTEMBER").unwrap(), Month::September);
assert_eq!(Month::from_str("Sep").unwrap(), Month::September);
assert_eq!(Month::from_str("sep").unwrap(), Month::September);
assert_eq!(Month::from_str("SEP").unwrap(), Month::September);
assert_eq!(Month::from_str("10").unwrap(), Month::October);
assert_eq!(Month::from_str("October").unwrap(), Month::October);
assert_eq!(Month::from_str("october").unwrap(), Month::October);
assert_eq!(Month::from_str("OCTOBER").unwrap(), Month::October);
assert_eq!(Month::from_str("Oct").unwrap(), Month::October);
assert_eq!(Month::from_str("oct").unwrap(), Month::October);
assert_eq!(Month::from_str("OCT").unwrap(), Month::October);
assert_eq!(Month::from_str("11").unwrap(), Month::November);
assert_eq!(Month::from_str("November").unwrap(), Month::November);
assert_eq!(Month::from_str("november").unwrap(), Month::November);
assert_eq!(Month::from_str("NOVEMBER").unwrap(), Month::November);
assert_eq!(Month::from_str("Nov").unwrap(), Month::November);
assert_eq!(Month::from_str("nov").unwrap(), Month::November);
assert_eq!(Month::from_str("NOV").unwrap(), Month::November);
assert_eq!(Month::from_str("12").unwrap(), Month::December);
assert_eq!(Month::from_str("December").unwrap(), Month::December);
assert_eq!(Month::from_str("december").unwrap(), Month::December);
assert_eq!(Month::from_str("DECEMBER").unwrap(), Month::December);
assert_eq!(Month::from_str("Dec").unwrap(), Month::December);
assert_eq!(Month::from_str("dec").unwrap(), Month::December);
assert_eq!(Month::from_str("DEC").unwrap(), Month::December);sourcepub const fn from_bytes(bytes: &[u8]) -> Option<Self>
pub const fn from_bytes(bytes: &[u8]) -> Option<Self>
sourcepub const fn inner(self) -> u8
pub const fn inner(self) -> u8
assert_eq!(Month::January.inner(), 1);
assert_eq!(Month::February.inner(), 2);
assert_eq!(Month::March.inner(), 3);
assert_eq!(Month::April.inner(), 4);
assert_eq!(Month::May.inner(), 5);
assert_eq!(Month::June.inner(), 6);
assert_eq!(Month::July.inner(), 7);
assert_eq!(Month::August.inner(), 8);
assert_eq!(Month::September.inner(), 9);
assert_eq!(Month::October.inner(), 10);
assert_eq!(Month::November.inner(), 11);
assert_eq!(Month::December.inner(), 12);Trait Implementations§
source§impl<'__de> BorrowDecode<'__de> for Month
impl<'__de> BorrowDecode<'__de> for Month
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 Month
impl<'de> Deserialize<'de> for Month
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 Ord for Month
impl Ord for Month
source§impl PartialEq<i128> for Month
impl PartialEq<i128> for Month
source§impl PartialEq<isize> for Month
impl PartialEq<isize> for Month
source§impl PartialEq<u128> for Month
impl PartialEq<u128> for Month
source§impl PartialEq<usize> for Month
impl PartialEq<usize> for Month
source§impl PartialEq for Month
impl PartialEq for Month
source§impl PartialOrd for Month
impl PartialOrd for Month
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 Month
impl Eq for Month
impl StructuralEq for Month
impl StructuralPartialEq for Month
Auto Trait Implementations§
impl RefUnwindSafe for Month
impl Send for Month
impl Sync for Month
impl Unpin for Month
impl UnwindSafe for Month
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