summaryrefslogtreecommitdiff
path: root/src/weekday.rs
diff options
context:
space:
mode:
authorBotahamec <botahamec@outlook.com>2022-03-16 14:52:31 -0400
committerBotahamec <botahamec@outlook.com>2022-03-16 14:52:31 -0400
commite0e0a18a4bc873583e973d771669e88a92b20d92 (patch)
treeba060d810c4621ec7e489afb19ad180a6b2ab755 /src/weekday.rs
parent5ca69f1830763b689bae9c4873a2912b3f1e23b1 (diff)
parent954cfd1385709d41ef0ece9c78b8dcee236f55e4 (diff)
Merge branch 'master' of https://github.com/botahamec/botic
Diffstat (limited to 'src/weekday.rs')
-rw-r--r--src/weekday.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/weekday.rs b/src/weekday.rs
index d678b9f..d194a1c 100644
--- a/src/weekday.rs
+++ b/src/weekday.rs
@@ -30,6 +30,7 @@ impl Weekday {
/// assert_eq!(Weekday::Monday, Weekday::from_name("Monday").unwrap());
/// assert_eq!(None, Weekday::from_name("monday"));
/// ```
+ #[must_use]
pub fn from_name(name: &str) -> Option<Self> {
match name {
"Monday" => Some(Monday),
@@ -52,6 +53,7 @@ impl Weekday {
///
/// assert_eq!(Weekday::Tuesday, Weekday::Monday.next());
/// ```
+ #[must_use]
pub const fn next(self) -> Self {
match self {
Monday => Tuesday,
@@ -73,6 +75,7 @@ impl Weekday {
///
/// assert_eq!(Weekday::Sunday, Weekday::Monday.previous());
/// ```
+ #[must_use]
pub const fn previous(self) -> Self {
match self {
Monday => Sunday,
@@ -97,6 +100,7 @@ impl Weekday {
/// assert_eq!(0, Weekday::Monday.number_days_from_monday());
/// assert_eq!(6, Weekday::Sunday.number_days_from_monday());
/// ```
+ #[must_use]
pub const fn number_days_from_monday(self) -> u8 {
self as u8
}
@@ -113,6 +117,7 @@ impl Weekday {
/// assert_eq!(1, Weekday::Monday.number_from_monday());
/// assert_eq!(7, Weekday::Sunday.number_from_monday());
/// ```
+ #[must_use]
pub const fn number_from_monday(self) -> u8 {
self.number_days_from_monday() + 1
}
@@ -130,6 +135,7 @@ impl Weekday {
/// assert_eq!(1, Weekday::Monday.number_days_from_sunday());
/// ```
// TODO benchmark this
+ #[must_use]
pub const fn number_days_from_sunday(self) -> u8 {
match self {
Sunday => 0,
@@ -149,6 +155,7 @@ impl Weekday {
/// assert_eq!(1, Weekday::Sunday.number_from_sunday());
/// assert_eq!(2, Weekday::Monday.number_from_sunday());
/// ```
+ #[must_use]
pub const fn number_from_sunday(self) -> u8 {
self.number_days_from_sunday() + 1
}