#[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.
This enum is used by Utc2k to differentiate between calendar months.
§Examples
use utc2k::Month;
// The first.
assert_eq!(Month::January as u8, 1_u8);
assert_eq!(Month::January.as_str(), "January");
assert_eq!(Month::January.abbreviation(), "Jan");
// The last.
assert_eq!(Month::December as u8, 12_u8);
assert_eq!(Month::December.as_str(), "December");
assert_eq!(Month::December.abbreviation(), "Dec");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 fn abbreviation(self) -> &'static str
pub const fn abbreviation(self) -> &'static str
§As String Slice (Abbreviated).
Return the three-letter abbreviation for a given month as a static string slice.
§Examples
use utc2k::Month;
assert_eq!(Month::January.abbreviation(), "Jan");
assert_eq!(Month::February.abbreviation(), "Feb");
assert_eq!(Month::March.abbreviation(), "Mar");
assert_eq!(Month::April.abbreviation(), "Apr");
assert_eq!(Month::May.abbreviation(), "May");
assert_eq!(Month::June.abbreviation(), "Jun");
assert_eq!(Month::July.abbreviation(), "Jul");
assert_eq!(Month::August.abbreviation(), "Aug");
assert_eq!(Month::September.abbreviation(), "Sep");
assert_eq!(Month::October.abbreviation(), "Oct");
assert_eq!(Month::November.abbreviation(), "Nov");
assert_eq!(Month::December.abbreviation(), "Dec");Sourcepub const fn as_str(self) -> &'static str
pub const fn as_str(self) -> &'static str
§As String Slice.
Return the name of a given month as a static string slice.
§Examples
use utc2k::Month;
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 previous(self) -> Self
pub const fn previous(self) -> Self
§Previous Month (Wrapping).
Return the previous Month.
§Examples
use utc2k::Month;
assert_eq!(Month::January.previous(), Month::December);
assert_eq!(Month::February.previous(), Month::January);
assert_eq!(Month::March.previous(), Month::February);
assert_eq!(Month::April.previous(), Month::March);
assert_eq!(Month::May.previous(), Month::April);
assert_eq!(Month::June.previous(), Month::May);
assert_eq!(Month::July.previous(), Month::June);
assert_eq!(Month::August.previous(), Month::July);
assert_eq!(Month::September.previous(), Month::August);
assert_eq!(Month::October.previous(), Month::September);
assert_eq!(Month::November.previous(), Month::October);
assert_eq!(Month::December.previous(), Month::November);
// Same as math:
assert_eq!(Month::January.previous(), Month::January - 1_u8);
// Same as the proper iterator too (provided you skip the first value):
assert_eq!(
Some(Month::January.previous()),
Month::January.into_iter().rev().skip(1).next(),
);Sourcepub const fn next(self) -> Self
pub const fn next(self) -> Self
§Next Month (Wrapping).
Return the next Month.
§Examples
use utc2k::Month;
assert_eq!(Month::January.next(), Month::February);
assert_eq!(Month::February.next(), Month::March);
assert_eq!(Month::March.next(), Month::April);
assert_eq!(Month::April.next(), Month::May);
assert_eq!(Month::May.next(), Month::June);
assert_eq!(Month::June.next(), Month::July);
assert_eq!(Month::July.next(), Month::August);
assert_eq!(Month::August.next(), Month::September);
assert_eq!(Month::September.next(), Month::October);
assert_eq!(Month::October.next(), Month::November);
assert_eq!(Month::November.next(), Month::December);
assert_eq!(Month::December.next(), Month::January);
// Same as math:
assert_eq!(Month::January.next(), Month::January + 1_u8);
// Same as the proper iterator too (provided you skip the first value):
assert_eq!(
Some(Month::January.next()),
Month::January.into_iter().skip(1).next(),
);Sourcepub const fn cmp(a: Self, b: Self) -> Ordering
pub const fn cmp(a: Self, b: Self) -> Ordering
§Compare Two Months.
Same as Ord/PartialOrd, but constant.
§Examples
use utc2k::Month;
assert_eq!(
Month::January.cmp(&Month::January),
Month::cmp(Month::January, Month::January), // Ordering::Equal
);
assert_eq!(
Month::January.cmp(&Month::December),
Month::cmp(Month::January, Month::December), // Ordering::Less
);
assert_eq!(
Month::December.cmp(&Month::January),
Month::cmp(Month::December, Month::January), // Ordering::Greater
);Source§impl Month
impl Month
Sourcepub const fn days(self) -> u8
pub const fn days(self) -> u8
§Month Size (Days).
This returns the total number of days this month could hold, or put another way, the last day of this month.
Note: this method is not leap-aware. If the month is February and it is
in a leap year, be sure to add 1 to reach 29!
§Examples
use utc2k::Month;
assert_eq!(Month::January.days(), 31);
assert_eq!(Month::February.days(), 28); // Not leap-aware.
assert_eq!(Month::March.days(), 31);
assert_eq!(Month::April.days(), 30);
// …Trait Implementations§
Source§impl Add<u16> for Month
impl Add<u16> for Month
Source§fn add(self, other: u16) -> Self
fn add(self, other: u16) -> Self
§Wrapping u16 Addition.
Months range from 1..=12, starting with January.
§Examples
use utc2k::Month;
let start = Month::January;
assert_eq!(start + 0_u16, Month::January); // Noop.
assert_eq!(start + 1_u16, Month::February);
assert_eq!(start + 2_u16, Month::March);
assert_eq!(start + 3_u16, Month::April);
assert_eq!(start + 4_u16, Month::May);
assert_eq!(start + 5_u16, Month::June);
assert_eq!(start + 6_u16, Month::July);
assert_eq!(start + 7_u16, Month::August);
assert_eq!(start + 8_u16, Month::September);
assert_eq!(start + 9_u16, Month::October);
assert_eq!(start + 10_u16, Month::November);
assert_eq!(start + 11_u16, Month::December);
assert_eq!(start + 12_u16, Month::January); // Wrap.
assert_eq!(start + 13_u16, Month::February); // Wrap.
assert_eq!(start + 14_u16, Month::March); // Wrap.
// …Source§impl Add<u32> for Month
impl Add<u32> for Month
Source§fn add(self, other: u32) -> Self
fn add(self, other: u32) -> Self
§Wrapping u32 Addition.
Months range from 1..=12, starting with January.
§Examples
use utc2k::Month;
let start = Month::January;
assert_eq!(start + 0_u32, Month::January); // Noop.
assert_eq!(start + 1_u32, Month::February);
assert_eq!(start + 2_u32, Month::March);
assert_eq!(start + 3_u32, Month::April);
assert_eq!(start + 4_u32, Month::May);
assert_eq!(start + 5_u32, Month::June);
assert_eq!(start + 6_u32, Month::July);
assert_eq!(start + 7_u32, Month::August);
assert_eq!(start + 8_u32, Month::September);
assert_eq!(start + 9_u32, Month::October);
assert_eq!(start + 10_u32, Month::November);
assert_eq!(start + 11_u32, Month::December);
assert_eq!(start + 12_u32, Month::January); // Wrap.
assert_eq!(start + 13_u32, Month::February); // Wrap.
assert_eq!(start + 14_u32, Month::March); // Wrap.
// …Source§impl Add<u64> for Month
impl Add<u64> for Month
Source§fn add(self, other: u64) -> Self
fn add(self, other: u64) -> Self
§Wrapping u64 Addition.
Months range from 1..=12, starting with January.
§Examples
use utc2k::Month;
let start = Month::January;
assert_eq!(start + 0_u64, Month::January); // Noop.
assert_eq!(start + 1_u64, Month::February);
assert_eq!(start + 2_u64, Month::March);
assert_eq!(start + 3_u64, Month::April);
assert_eq!(start + 4_u64, Month::May);
assert_eq!(start + 5_u64, Month::June);
assert_eq!(start + 6_u64, Month::July);
assert_eq!(start + 7_u64, Month::August);
assert_eq!(start + 8_u64, Month::September);
assert_eq!(start + 9_u64, Month::October);
assert_eq!(start + 10_u64, Month::November);
assert_eq!(start + 11_u64, Month::December);
assert_eq!(start + 12_u64, Month::January); // Wrap.
assert_eq!(start + 13_u64, Month::February); // Wrap.
assert_eq!(start + 14_u64, Month::March); // Wrap.
// …Source§impl Add<u8> for Month
impl Add<u8> for Month
Source§fn add(self, other: u8) -> Self
fn add(self, other: u8) -> Self
§Wrapping u8 Addition.
Months range from 1..=12, starting with January.
§Examples
use utc2k::Month;
let start = Month::January;
assert_eq!(start + 0_u8, Month::January); // Noop.
assert_eq!(start + 1_u8, Month::February);
assert_eq!(start + 2_u8, Month::March);
assert_eq!(start + 3_u8, Month::April);
assert_eq!(start + 4_u8, Month::May);
assert_eq!(start + 5_u8, Month::June);
assert_eq!(start + 6_u8, Month::July);
assert_eq!(start + 7_u8, Month::August);
assert_eq!(start + 8_u8, Month::September);
assert_eq!(start + 9_u8, Month::October);
assert_eq!(start + 10_u8, Month::November);
assert_eq!(start + 11_u8, Month::December);
assert_eq!(start + 12_u8, Month::January); // Wrap.
assert_eq!(start + 13_u8, Month::February); // Wrap.
assert_eq!(start + 14_u8, Month::March); // Wrap.
// …Source§impl Add<usize> for Month
impl Add<usize> for Month
Source§fn add(self, other: usize) -> Self
fn add(self, other: usize) -> Self
§Wrapping usize Addition.
Months range from 1..=12, starting with January.
§Examples
use utc2k::Month;
let start = Month::January;
assert_eq!(start + 0_usize, Month::January); // Noop.
assert_eq!(start + 1_usize, Month::February);
assert_eq!(start + 2_usize, Month::March);
assert_eq!(start + 3_usize, Month::April);
assert_eq!(start + 4_usize, Month::May);
assert_eq!(start + 5_usize, Month::June);
assert_eq!(start + 6_usize, Month::July);
assert_eq!(start + 7_usize, Month::August);
assert_eq!(start + 8_usize, Month::September);
assert_eq!(start + 9_usize, Month::October);
assert_eq!(start + 10_usize, Month::November);
assert_eq!(start + 11_usize, Month::December);
assert_eq!(start + 12_usize, Month::January); // Wrap.
assert_eq!(start + 13_usize, Month::February); // Wrap.
assert_eq!(start + 14_usize, Month::March); // Wrap.
// …Source§impl AddAssign<u16> for Month
impl AddAssign<u16> for Month
Source§fn add_assign(&mut self, other: u16)
fn add_assign(&mut self, other: u16)
+= operation. Read moreSource§impl AddAssign<u32> for Month
impl AddAssign<u32> for Month
Source§fn add_assign(&mut self, other: u32)
fn add_assign(&mut self, other: u32)
+= operation. Read moreSource§impl AddAssign<u64> for Month
impl AddAssign<u64> for Month
Source§fn add_assign(&mut self, other: u64)
fn add_assign(&mut self, other: u64)
+= operation. Read moreSource§impl AddAssign<u8> for Month
impl AddAssign<u8> for Month
Source§fn add_assign(&mut self, other: u8)
fn add_assign(&mut self, other: u8)
+= operation. Read moreSource§impl AddAssign<usize> for Month
impl AddAssign<usize> for Month
Source§fn add_assign(&mut self, other: usize)
fn add_assign(&mut self, other: usize)
+= operation. Read moreSource§impl<'de> Deserialize<'de> for Month
Available on crate feature serde only.
impl<'de> Deserialize<'de> for Month
serde only.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.
Use the optional serde crate feature to enable serialization support.
Source§impl From<Month> for u16
impl From<Month> for u16
Source§fn from(src: Month) -> Self
fn from(src: Month) -> Self
§u16 From Month.
Months range from 1..=12, starting with January.
§Examples
use utc2k::Month;
assert_eq!(u16::from(Month::January), 1);
assert_eq!(u16::from(Month::February), 2);
assert_eq!(u16::from(Month::March), 3);
assert_eq!(u16::from(Month::April), 4);
assert_eq!(u16::from(Month::May), 5);
assert_eq!(u16::from(Month::June), 6);
assert_eq!(u16::from(Month::July), 7);
assert_eq!(u16::from(Month::August), 8);
assert_eq!(u16::from(Month::September), 9);
assert_eq!(u16::from(Month::October), 10);
assert_eq!(u16::from(Month::November), 11);
assert_eq!(u16::from(Month::December), 12);
// Same as `as` casting.
for v in Month::ALL {
assert_eq!(u16::from(v), v as u16);
}Source§impl From<Month> for u32
impl From<Month> for u32
Source§fn from(src: Month) -> Self
fn from(src: Month) -> Self
§u32 From Month.
Months range from 1..=12, starting with January.
§Examples
use utc2k::Month;
assert_eq!(u32::from(Month::January), 1);
assert_eq!(u32::from(Month::February), 2);
assert_eq!(u32::from(Month::March), 3);
assert_eq!(u32::from(Month::April), 4);
assert_eq!(u32::from(Month::May), 5);
assert_eq!(u32::from(Month::June), 6);
assert_eq!(u32::from(Month::July), 7);
assert_eq!(u32::from(Month::August), 8);
assert_eq!(u32::from(Month::September), 9);
assert_eq!(u32::from(Month::October), 10);
assert_eq!(u32::from(Month::November), 11);
assert_eq!(u32::from(Month::December), 12);
// Same as `as` casting.
for v in Month::ALL {
assert_eq!(u32::from(v), v as u32);
}Source§impl From<Month> for u64
impl From<Month> for u64
Source§fn from(src: Month) -> Self
fn from(src: Month) -> Self
§u64 From Month.
Months range from 1..=12, starting with January.
§Examples
use utc2k::Month;
assert_eq!(u64::from(Month::January), 1);
assert_eq!(u64::from(Month::February), 2);
assert_eq!(u64::from(Month::March), 3);
assert_eq!(u64::from(Month::April), 4);
assert_eq!(u64::from(Month::May), 5);
assert_eq!(u64::from(Month::June), 6);
assert_eq!(u64::from(Month::July), 7);
assert_eq!(u64::from(Month::August), 8);
assert_eq!(u64::from(Month::September), 9);
assert_eq!(u64::from(Month::October), 10);
assert_eq!(u64::from(Month::November), 11);
assert_eq!(u64::from(Month::December), 12);
// Same as `as` casting.
for v in Month::ALL {
assert_eq!(u64::from(v), v as u64);
}Source§impl From<Month> for u8
impl From<Month> for u8
Source§fn from(src: Month) -> Self
fn from(src: Month) -> Self
§u8 From Month.
Months range from 1..=12, starting with January.
§Examples
use utc2k::Month;
assert_eq!(u8::from(Month::January), 1);
assert_eq!(u8::from(Month::February), 2);
assert_eq!(u8::from(Month::March), 3);
assert_eq!(u8::from(Month::April), 4);
assert_eq!(u8::from(Month::May), 5);
assert_eq!(u8::from(Month::June), 6);
assert_eq!(u8::from(Month::July), 7);
assert_eq!(u8::from(Month::August), 8);
assert_eq!(u8::from(Month::September), 9);
assert_eq!(u8::from(Month::October), 10);
assert_eq!(u8::from(Month::November), 11);
assert_eq!(u8::from(Month::December), 12);
// Same as `as` casting.
for v in Month::ALL {
assert_eq!(u8::from(v), v as u8);
}Source§impl From<Month> for usize
impl From<Month> for usize
Source§fn from(src: Month) -> Self
fn from(src: Month) -> Self
§usize From Month.
Months range from 1..=12, starting with January.
§Examples
use utc2k::Month;
assert_eq!(usize::from(Month::January), 1);
assert_eq!(usize::from(Month::February), 2);
assert_eq!(usize::from(Month::March), 3);
assert_eq!(usize::from(Month::April), 4);
assert_eq!(usize::from(Month::May), 5);
assert_eq!(usize::from(Month::June), 6);
assert_eq!(usize::from(Month::July), 7);
assert_eq!(usize::from(Month::August), 8);
assert_eq!(usize::from(Month::September), 9);
assert_eq!(usize::from(Month::October), 10);
assert_eq!(usize::from(Month::November), 11);
assert_eq!(usize::from(Month::December), 12);
// Same as `as` casting.
for v in Month::ALL {
assert_eq!(usize::from(v), v as usize);
}Source§impl From<u16> for Month
impl From<u16> for Month
Source§fn from(src: u16) -> Self
fn from(src: u16) -> Self
§Month From u16 (Wrapping).
Months range from 1..=12, starting with January.
§Examples
use utc2k::Month;
assert_eq!(Month::from(0_u16), Month::December); // Wrap.
assert_eq!(Month::from(1_u16), Month::January);
assert_eq!(Month::from(2_u16), Month::February);
assert_eq!(Month::from(3_u16), Month::March);
assert_eq!(Month::from(4_u16), Month::April);
assert_eq!(Month::from(5_u16), Month::May);
assert_eq!(Month::from(6_u16), Month::June);
assert_eq!(Month::from(7_u16), Month::July);
assert_eq!(Month::from(8_u16), Month::August);
assert_eq!(Month::from(9_u16), Month::September);
assert_eq!(Month::from(10_u16), Month::October);
assert_eq!(Month::from(11_u16), Month::November);
assert_eq!(Month::from(12_u16), Month::December);
assert_eq!(Month::from(13_u16), Month::January); // Wrap.
assert_eq!(Month::from(14_u16), Month::February); // Wrap.
assert_eq!(Month::from(15_u16), Month::March); // Wrap.
// …Source§impl From<u32> for Month
impl From<u32> for Month
Source§fn from(src: u32) -> Self
fn from(src: u32) -> Self
§Month From u32 (Wrapping).
Months range from 1..=12, starting with January.
§Examples
use utc2k::Month;
assert_eq!(Month::from(0_u32), Month::December); // Wrap.
assert_eq!(Month::from(1_u32), Month::January);
assert_eq!(Month::from(2_u32), Month::February);
assert_eq!(Month::from(3_u32), Month::March);
assert_eq!(Month::from(4_u32), Month::April);
assert_eq!(Month::from(5_u32), Month::May);
assert_eq!(Month::from(6_u32), Month::June);
assert_eq!(Month::from(7_u32), Month::July);
assert_eq!(Month::from(8_u32), Month::August);
assert_eq!(Month::from(9_u32), Month::September);
assert_eq!(Month::from(10_u32), Month::October);
assert_eq!(Month::from(11_u32), Month::November);
assert_eq!(Month::from(12_u32), Month::December);
assert_eq!(Month::from(13_u32), Month::January); // Wrap.
assert_eq!(Month::from(14_u32), Month::February); // Wrap.
assert_eq!(Month::from(15_u32), Month::March); // Wrap.
// …Source§impl From<u64> for Month
impl From<u64> for Month
Source§fn from(src: u64) -> Self
fn from(src: u64) -> Self
§Month From u64 (Wrapping).
Months range from 1..=12, starting with January.
§Examples
use utc2k::Month;
assert_eq!(Month::from(0_u64), Month::December); // Wrap.
assert_eq!(Month::from(1_u64), Month::January);
assert_eq!(Month::from(2_u64), Month::February);
assert_eq!(Month::from(3_u64), Month::March);
assert_eq!(Month::from(4_u64), Month::April);
assert_eq!(Month::from(5_u64), Month::May);
assert_eq!(Month::from(6_u64), Month::June);
assert_eq!(Month::from(7_u64), Month::July);
assert_eq!(Month::from(8_u64), Month::August);
assert_eq!(Month::from(9_u64), Month::September);
assert_eq!(Month::from(10_u64), Month::October);
assert_eq!(Month::from(11_u64), Month::November);
assert_eq!(Month::from(12_u64), Month::December);
assert_eq!(Month::from(13_u64), Month::January); // Wrap.
assert_eq!(Month::from(14_u64), Month::February); // Wrap.
assert_eq!(Month::from(15_u64), Month::March); // Wrap.
// …Source§impl From<u8> for Month
impl From<u8> for Month
Source§fn from(src: u8) -> Self
fn from(src: u8) -> Self
§Month From u8 (Wrapping).
Months range from 1..=12, starting with January.
§Examples
use utc2k::Month;
assert_eq!(Month::from(0_u8), Month::December); // Wrap.
assert_eq!(Month::from(1_u8), Month::January);
assert_eq!(Month::from(2_u8), Month::February);
assert_eq!(Month::from(3_u8), Month::March);
assert_eq!(Month::from(4_u8), Month::April);
assert_eq!(Month::from(5_u8), Month::May);
assert_eq!(Month::from(6_u8), Month::June);
assert_eq!(Month::from(7_u8), Month::July);
assert_eq!(Month::from(8_u8), Month::August);
assert_eq!(Month::from(9_u8), Month::September);
assert_eq!(Month::from(10_u8), Month::October);
assert_eq!(Month::from(11_u8), Month::November);
assert_eq!(Month::from(12_u8), Month::December);
assert_eq!(Month::from(13_u8), Month::January); // Wrap.
assert_eq!(Month::from(14_u8), Month::February); // Wrap.
assert_eq!(Month::from(15_u8), Month::March); // Wrap.
// …Source§impl From<usize> for Month
impl From<usize> for Month
Source§fn from(src: usize) -> Self
fn from(src: usize) -> Self
§Month From usize (Wrapping).
Months range from 1..=12, starting with January.
§Examples
use utc2k::Month;
assert_eq!(Month::from(0_usize), Month::December); // Wrap.
assert_eq!(Month::from(1_usize), Month::January);
assert_eq!(Month::from(2_usize), Month::February);
assert_eq!(Month::from(3_usize), Month::March);
assert_eq!(Month::from(4_usize), Month::April);
assert_eq!(Month::from(5_usize), Month::May);
assert_eq!(Month::from(6_usize), Month::June);
assert_eq!(Month::from(7_usize), Month::July);
assert_eq!(Month::from(8_usize), Month::August);
assert_eq!(Month::from(9_usize), Month::September);
assert_eq!(Month::from(10_usize), Month::October);
assert_eq!(Month::from(11_usize), Month::November);
assert_eq!(Month::from(12_usize), Month::December);
assert_eq!(Month::from(13_usize), Month::January); // Wrap.
assert_eq!(Month::from(14_usize), Month::February); // Wrap.
assert_eq!(Month::from(15_usize), Month::March); // Wrap.
// …Source§impl FromStr for Month
impl FromStr for Month
Source§fn from_str(src: &str) -> Result<Self, Self::Err>
fn from_str(src: &str) -> Result<Self, Self::Err>
§Parse From String.
Parse a Month from the first three letters of a string, case-insensitively.
§Examples
use utc2k::Month;
for v in Month::ALL {
assert_eq!(v.as_str().parse::<Month>(), Ok(v));
assert_eq!(v.abbreviation().parse::<Month>(), Ok(v));
}
// Remember that only the first three letters count!
assert_eq!("Janissary".parse::<Month>(), Ok(Month::January));Source§type Err = Utc2kError
type Err = Utc2kError
Source§impl IntoIterator for Month
impl IntoIterator for Month
Source§fn into_iter(self) -> Self::IntoIter
fn into_iter(self) -> Self::IntoIter
§Endless Month Iterator.
Return an iterator that will cycle endlessly through the months, in order, forward or backward, starting with self.
§Examples
use utc2k::Month;
let mut iter = Month::January.into_iter();
assert_eq!(iter.next(), Some(Month::January));
assert_eq!(iter.next(), Some(Month::February));
assert_eq!(iter.next(), Some(Month::March));
assert_eq!(iter.next(), Some(Month::April));
assert_eq!(iter.next(), Some(Month::May));
assert_eq!(iter.next(), Some(Month::June));
assert_eq!(iter.next(), Some(Month::July));
assert_eq!(iter.next(), Some(Month::August));
assert_eq!(iter.next(), Some(Month::September));
assert_eq!(iter.next(), Some(Month::October));
assert_eq!(iter.next(), Some(Month::November));
assert_eq!(iter.next(), Some(Month::December));
assert_eq!(iter.next(), Some(Month::January)); // Wrap.
assert_eq!(iter.next(), Some(Month::February)); // Wrap.
assert_eq!(iter.next(), Some(Month::March)); // Wrap.
// …
// Or like Ginger:
let mut iter = Month::December.into_iter().rev();
assert_eq!(iter.next(), Some(Month::December));
assert_eq!(iter.next(), Some(Month::November));
assert_eq!(iter.next(), Some(Month::October));
assert_eq!(iter.next(), Some(Month::September));
assert_eq!(iter.next(), Some(Month::August));
assert_eq!(iter.next(), Some(Month::July));
assert_eq!(iter.next(), Some(Month::June));
assert_eq!(iter.next(), Some(Month::May));
assert_eq!(iter.next(), Some(Month::April));
assert_eq!(iter.next(), Some(Month::March));
assert_eq!(iter.next(), Some(Month::February));
assert_eq!(iter.next(), Some(Month::January));
assert_eq!(iter.next(), Some(Month::December)); // Wrap.
assert_eq!(iter.next(), Some(Month::November)); // Wrap.
assert_eq!(iter.next(), Some(Month::October)); // Wrap.
// …Source§impl Ord for Month
impl Ord for Month
Source§impl PartialEq<Month> for u16
impl PartialEq<Month> for u16
Source§fn eq(&self, other: &Month) -> bool
fn eq(&self, other: &Month) -> bool
§u16/Month Equality.
use utc2k::Month;
assert_eq!(1_u16, Month::January);
assert_eq!(2_u16, Month::February);
assert_eq!(3_u16, Month::March);
assert_eq!(4_u16, Month::April);
assert_eq!(5_u16, Month::May);
assert_eq!(6_u16, Month::June);
assert_eq!(7_u16, Month::July);
assert_eq!(8_u16, Month::August);
assert_eq!(9_u16, Month::September);
assert_eq!(10_u16, Month::October);
assert_eq!(11_u16, Month::November);
assert_eq!(12_u16, Month::December);// Nope. assert_ne!(u16::MIN, Month::January);
Source§impl PartialEq<Month> for u32
impl PartialEq<Month> for u32
Source§fn eq(&self, other: &Month) -> bool
fn eq(&self, other: &Month) -> bool
§u32/Month Equality.
use utc2k::Month;
assert_eq!(1_u32, Month::January);
assert_eq!(2_u32, Month::February);
assert_eq!(3_u32, Month::March);
assert_eq!(4_u32, Month::April);
assert_eq!(5_u32, Month::May);
assert_eq!(6_u32, Month::June);
assert_eq!(7_u32, Month::July);
assert_eq!(8_u32, Month::August);
assert_eq!(9_u32, Month::September);
assert_eq!(10_u32, Month::October);
assert_eq!(11_u32, Month::November);
assert_eq!(12_u32, Month::December);// Nope. assert_ne!(u32::MIN, Month::January);
Source§impl PartialEq<Month> for u64
impl PartialEq<Month> for u64
Source§fn eq(&self, other: &Month) -> bool
fn eq(&self, other: &Month) -> bool
§u64/Month Equality.
use utc2k::Month;
assert_eq!(1_u64, Month::January);
assert_eq!(2_u64, Month::February);
assert_eq!(3_u64, Month::March);
assert_eq!(4_u64, Month::April);
assert_eq!(5_u64, Month::May);
assert_eq!(6_u64, Month::June);
assert_eq!(7_u64, Month::July);
assert_eq!(8_u64, Month::August);
assert_eq!(9_u64, Month::September);
assert_eq!(10_u64, Month::October);
assert_eq!(11_u64, Month::November);
assert_eq!(12_u64, Month::December);// Nope. assert_ne!(u64::MIN, Month::January);
Source§impl PartialEq<Month> for u8
impl PartialEq<Month> for u8
Source§fn eq(&self, other: &Month) -> bool
fn eq(&self, other: &Month) -> bool
§u8/Month Equality.
use utc2k::Month;
assert_eq!(1_u8, Month::January);
assert_eq!(2_u8, Month::February);
assert_eq!(3_u8, Month::March);
assert_eq!(4_u8, Month::April);
assert_eq!(5_u8, Month::May);
assert_eq!(6_u8, Month::June);
assert_eq!(7_u8, Month::July);
assert_eq!(8_u8, Month::August);
assert_eq!(9_u8, Month::September);
assert_eq!(10_u8, Month::October);
assert_eq!(11_u8, Month::November);
assert_eq!(12_u8, Month::December);// Nope. assert_ne!(u8::MIN, Month::January);
Source§impl PartialEq<Month> for usize
impl PartialEq<Month> for usize
Source§fn eq(&self, other: &Month) -> bool
fn eq(&self, other: &Month) -> bool
§usize/Month Equality.
use utc2k::Month;
assert_eq!(1_usize, Month::January);
assert_eq!(2_usize, Month::February);
assert_eq!(3_usize, Month::March);
assert_eq!(4_usize, Month::April);
assert_eq!(5_usize, Month::May);
assert_eq!(6_usize, Month::June);
assert_eq!(7_usize, Month::July);
assert_eq!(8_usize, Month::August);
assert_eq!(9_usize, Month::September);
assert_eq!(10_usize, Month::October);
assert_eq!(11_usize, Month::November);
assert_eq!(12_usize, Month::December);// Nope. assert_ne!(usize::MIN, Month::January);
Source§impl PartialEq<u16> for Month
impl PartialEq<u16> for Month
Source§fn eq(&self, other: &u16) -> bool
fn eq(&self, other: &u16) -> bool
§Month/u16 Equality.
use utc2k::Month;
assert_eq!(Month::January, 1_u16);
assert_eq!(Month::February, 2_u16);
assert_eq!(Month::March, 3_u16);
assert_eq!(Month::April, 4_u16);
assert_eq!(Month::May, 5_u16);
assert_eq!(Month::June, 6_u16);
assert_eq!(Month::July, 7_u16);
assert_eq!(Month::August, 8_u16);
assert_eq!(Month::September, 9_u16);
assert_eq!(Month::October, 10_u16);
assert_eq!(Month::November, 11_u16);
assert_eq!(Month::December, 12_u16);
// Nope.
assert_ne!(Month::January, u16::MIN);Source§impl PartialEq<u32> for Month
impl PartialEq<u32> for Month
Source§fn eq(&self, other: &u32) -> bool
fn eq(&self, other: &u32) -> bool
§Month/u32 Equality.
use utc2k::Month;
assert_eq!(Month::January, 1_u32);
assert_eq!(Month::February, 2_u32);
assert_eq!(Month::March, 3_u32);
assert_eq!(Month::April, 4_u32);
assert_eq!(Month::May, 5_u32);
assert_eq!(Month::June, 6_u32);
assert_eq!(Month::July, 7_u32);
assert_eq!(Month::August, 8_u32);
assert_eq!(Month::September, 9_u32);
assert_eq!(Month::October, 10_u32);
assert_eq!(Month::November, 11_u32);
assert_eq!(Month::December, 12_u32);
// Nope.
assert_ne!(Month::January, u32::MIN);Source§impl PartialEq<u64> for Month
impl PartialEq<u64> for Month
Source§fn eq(&self, other: &u64) -> bool
fn eq(&self, other: &u64) -> bool
§Month/u64 Equality.
use utc2k::Month;
assert_eq!(Month::January, 1_u64);
assert_eq!(Month::February, 2_u64);
assert_eq!(Month::March, 3_u64);
assert_eq!(Month::April, 4_u64);
assert_eq!(Month::May, 5_u64);
assert_eq!(Month::June, 6_u64);
assert_eq!(Month::July, 7_u64);
assert_eq!(Month::August, 8_u64);
assert_eq!(Month::September, 9_u64);
assert_eq!(Month::October, 10_u64);
assert_eq!(Month::November, 11_u64);
assert_eq!(Month::December, 12_u64);
// Nope.
assert_ne!(Month::January, u64::MIN);Source§impl PartialEq<u8> for Month
impl PartialEq<u8> for Month
Source§fn eq(&self, other: &u8) -> bool
fn eq(&self, other: &u8) -> bool
§Month/u8 Equality.
use utc2k::Month;
assert_eq!(Month::January, 1_u8);
assert_eq!(Month::February, 2_u8);
assert_eq!(Month::March, 3_u8);
assert_eq!(Month::April, 4_u8);
assert_eq!(Month::May, 5_u8);
assert_eq!(Month::June, 6_u8);
assert_eq!(Month::July, 7_u8);
assert_eq!(Month::August, 8_u8);
assert_eq!(Month::September, 9_u8);
assert_eq!(Month::October, 10_u8);
assert_eq!(Month::November, 11_u8);
assert_eq!(Month::December, 12_u8);
// Nope.
assert_ne!(Month::January, u8::MIN);Source§impl PartialEq<usize> for Month
impl PartialEq<usize> for Month
Source§fn eq(&self, other: &usize) -> bool
fn eq(&self, other: &usize) -> bool
§Month/usize Equality.
use utc2k::Month;
assert_eq!(Month::January, 1_usize);
assert_eq!(Month::February, 2_usize);
assert_eq!(Month::March, 3_usize);
assert_eq!(Month::April, 4_usize);
assert_eq!(Month::May, 5_usize);
assert_eq!(Month::June, 6_usize);
assert_eq!(Month::July, 7_usize);
assert_eq!(Month::August, 8_usize);
assert_eq!(Month::September, 9_usize);
assert_eq!(Month::October, 10_usize);
assert_eq!(Month::November, 11_usize);
assert_eq!(Month::December, 12_usize);
// Nope.
assert_ne!(Month::January, usize::MIN);Source§impl PartialOrd for Month
impl PartialOrd for Month
Source§impl Sub<u16> for Month
impl Sub<u16> for Month
Source§fn sub(self, other: u16) -> Self
fn sub(self, other: u16) -> Self
§Wrapping u16 Subtraction.
Months range from 1..=12, starting with January.
§Examples
use utc2k::Month;
let start = Month::January;
assert_eq!(start - 0_u16, Month::January); // Noop.
assert_eq!(start - 1_u16, Month::December);
assert_eq!(start - 2_u16, Month::November);
assert_eq!(start - 3_u16, Month::October);
assert_eq!(start - 4_u16, Month::September);
assert_eq!(start - 5_u16, Month::August);
assert_eq!(start - 6_u16, Month::July);
assert_eq!(start - 7_u16, Month::June);
assert_eq!(start - 8_u16, Month::May);
assert_eq!(start - 9_u16, Month::April);
assert_eq!(start - 10_u16, Month::March);
assert_eq!(start - 11_u16, Month::February);
assert_eq!(start - 12_u16, Month::January); // Wrap.
assert_eq!(start - 13_u16, Month::December); // Wrap.
assert_eq!(start - 14_u16, Month::November); // Wrap.
// …Source§impl Sub<u32> for Month
impl Sub<u32> for Month
Source§fn sub(self, other: u32) -> Self
fn sub(self, other: u32) -> Self
§Wrapping u32 Subtraction.
Months range from 1..=12, starting with January.
§Examples
use utc2k::Month;
let start = Month::January;
assert_eq!(start - 0_u32, Month::January); // Noop.
assert_eq!(start - 1_u32, Month::December);
assert_eq!(start - 2_u32, Month::November);
assert_eq!(start - 3_u32, Month::October);
assert_eq!(start - 4_u32, Month::September);
assert_eq!(start - 5_u32, Month::August);
assert_eq!(start - 6_u32, Month::July);
assert_eq!(start - 7_u32, Month::June);
assert_eq!(start - 8_u32, Month::May);
assert_eq!(start - 9_u32, Month::April);
assert_eq!(start - 10_u32, Month::March);
assert_eq!(start - 11_u32, Month::February);
assert_eq!(start - 12_u32, Month::January); // Wrap.
assert_eq!(start - 13_u32, Month::December); // Wrap.
assert_eq!(start - 14_u32, Month::November); // Wrap.
// …Source§impl Sub<u64> for Month
impl Sub<u64> for Month
Source§fn sub(self, other: u64) -> Self
fn sub(self, other: u64) -> Self
§Wrapping u64 Subtraction.
Months range from 1..=12, starting with January.
§Examples
use utc2k::Month;
let start = Month::January;
assert_eq!(start - 0_u64, Month::January); // Noop.
assert_eq!(start - 1_u64, Month::December);
assert_eq!(start - 2_u64, Month::November);
assert_eq!(start - 3_u64, Month::October);
assert_eq!(start - 4_u64, Month::September);
assert_eq!(start - 5_u64, Month::August);
assert_eq!(start - 6_u64, Month::July);
assert_eq!(start - 7_u64, Month::June);
assert_eq!(start - 8_u64, Month::May);
assert_eq!(start - 9_u64, Month::April);
assert_eq!(start - 10_u64, Month::March);
assert_eq!(start - 11_u64, Month::February);
assert_eq!(start - 12_u64, Month::January); // Wrap.
assert_eq!(start - 13_u64, Month::December); // Wrap.
assert_eq!(start - 14_u64, Month::November); // Wrap.
// …Source§impl Sub<u8> for Month
impl Sub<u8> for Month
Source§fn sub(self, other: u8) -> Self
fn sub(self, other: u8) -> Self
§Wrapping u8 Subtraction.
Months range from 1..=12, starting with January.
§Examples
use utc2k::Month;
let start = Month::January;
assert_eq!(start - 0_u8, Month::January); // Noop.
assert_eq!(start - 1_u8, Month::December);
assert_eq!(start - 2_u8, Month::November);
assert_eq!(start - 3_u8, Month::October);
assert_eq!(start - 4_u8, Month::September);
assert_eq!(start - 5_u8, Month::August);
assert_eq!(start - 6_u8, Month::July);
assert_eq!(start - 7_u8, Month::June);
assert_eq!(start - 8_u8, Month::May);
assert_eq!(start - 9_u8, Month::April);
assert_eq!(start - 10_u8, Month::March);
assert_eq!(start - 11_u8, Month::February);
assert_eq!(start - 12_u8, Month::January); // Wrap.
assert_eq!(start - 13_u8, Month::December); // Wrap.
assert_eq!(start - 14_u8, Month::November); // Wrap.
// …Source§impl Sub<usize> for Month
impl Sub<usize> for Month
Source§fn sub(self, other: usize) -> Self
fn sub(self, other: usize) -> Self
§Wrapping usize Subtraction.
Months range from 1..=12, starting with January.
§Examples
use utc2k::Month;
let start = Month::January;
assert_eq!(start - 0_usize, Month::January); // Noop.
assert_eq!(start - 1_usize, Month::December);
assert_eq!(start - 2_usize, Month::November);
assert_eq!(start - 3_usize, Month::October);
assert_eq!(start - 4_usize, Month::September);
assert_eq!(start - 5_usize, Month::August);
assert_eq!(start - 6_usize, Month::July);
assert_eq!(start - 7_usize, Month::June);
assert_eq!(start - 8_usize, Month::May);
assert_eq!(start - 9_usize, Month::April);
assert_eq!(start - 10_usize, Month::March);
assert_eq!(start - 11_usize, Month::February);
assert_eq!(start - 12_usize, Month::January); // Wrap.
assert_eq!(start - 13_usize, Month::December); // Wrap.
assert_eq!(start - 14_usize, Month::November); // Wrap.
// …Source§impl SubAssign<u16> for Month
impl SubAssign<u16> for Month
Source§fn sub_assign(&mut self, other: u16)
fn sub_assign(&mut self, other: u16)
-= operation. Read moreSource§impl SubAssign<u32> for Month
impl SubAssign<u32> for Month
Source§fn sub_assign(&mut self, other: u32)
fn sub_assign(&mut self, other: u32)
-= operation. Read moreSource§impl SubAssign<u64> for Month
impl SubAssign<u64> for Month
Source§fn sub_assign(&mut self, other: u64)
fn sub_assign(&mut self, other: u64)
-= operation. Read moreSource§impl SubAssign<u8> for Month
impl SubAssign<u8> for Month
Source§fn sub_assign(&mut self, other: u8)
fn sub_assign(&mut self, other: u8)
-= operation. Read moreSource§impl SubAssign<usize> for Month
impl SubAssign<usize> for Month
Source§fn sub_assign(&mut self, other: usize)
fn sub_assign(&mut self, other: usize)
-= operation. Read moreSource§impl TryFrom<&[u8]> for Month
impl TryFrom<&[u8]> for Month
Source§fn try_from(src: &[u8]) -> Result<Self, Self::Error>
fn try_from(src: &[u8]) -> Result<Self, Self::Error>
§From Byte Slice.
Parse a Month from the first three bytes of a slice,
case-insensitively.
§Examples
use utc2k::Month;
// Case doesn't matter.
assert_eq!(
Month::try_from(b"january".as_slice()),
Ok(Month::January),
);
assert_eq!(
Month::try_from(b"January".as_slice()),
Ok(Month::January),
);
assert_eq!(
Month::try_from(b"JANUARY".as_slice()),
Ok(Month::January),
);
// Only the first three bytes are actually inspected.
assert_eq!(
Month::try_from(b"Jan".as_slice()),
Ok(Month::January),
);
assert_eq!(
Month::try_from(b"janissary".as_slice()), // Close enough!
Ok(Month::January),
);
// Wrong is wrong.
assert!(Month::try_from(b"jebruary".as_slice()).is_err());Source§type Error = Utc2kError
type Error = Utc2kError
impl Copy for Month
impl Eq for Month
impl StructuralPartialEq for Month
Auto Trait Implementations§
impl Freeze for Month
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more