diff --git a/src/cli/error.rs b/src/cli/error.rs index 929650a..ef35e12 100644 --- a/src/cli/error.rs +++ b/src/cli/error.rs @@ -42,12 +42,12 @@ where { fn eprint<'f: 'a>(&self, files: &'f F, config: &Config) { match self { - Error::Eval(e) => e.eprint(files, config), - Error::ArgumentParse { file, error } => error.eprint(file, config), - Error::ArgumentEval { file, error } => error.eprint(file, config), - Error::NoSuchEntry(n) => eprintln!("No entry with number {n}"), - Error::NoSuchLog(date) => eprintln!("No log for {date}"), - Error::NotATask(ns) => { + Self::Eval(e) => e.eprint(files, config), + Self::ArgumentParse { file, error } => error.eprint(file, config), + Self::ArgumentEval { file, error } => error.eprint(file, config), + Self::NoSuchEntry(n) => eprintln!("No entry with number {n}"), + Self::NoSuchLog(date) => eprintln!("No log for {date}"), + Self::NotATask(ns) => { if ns.is_empty() { eprintln!("Not a task."); } else if ns.len() == 1 { @@ -57,8 +57,8 @@ where eprintln!("{} are not tasks.", ns.join(", ")); } } - Error::NoCaptureFile => eprintln!("No capture file found"), - Error::EditingIo(error) => { + Self::NoCaptureFile => eprintln!("No capture file found"), + Self::EditingIo(error) => { eprintln!("Error while editing:"); eprintln!(" {error}"); } diff --git a/src/cli/layout/line.rs b/src/cli/layout/line.rs index 42cd871..79d0a43 100644 --- a/src/cli/layout/line.rs +++ b/src/cli/layout/line.rs @@ -42,9 +42,9 @@ pub enum SpanSegment { impl SpanSegment { fn style(&self) -> SpanStyle { match self { - SpanSegment::Start(s) => *s, - SpanSegment::Middle(s) => *s, - SpanSegment::End(s) => *s, + Self::Start(s) => *s, + Self::Middle(s) => *s, + Self::End(s) => *s, } } } diff --git a/src/eval/command/birthday.rs b/src/eval/command/birthday.rs index cec1d2e..4f0cb32 100644 --- a/src/eval/command/birthday.rs +++ b/src/eval/command/birthday.rs @@ -8,7 +8,7 @@ use super::super::date::Dates; use super::super::error::Error; use super::super::EntryKind; -impl<'a> CommandState<'a> { +impl CommandState<'_> { pub fn eval_birthday_spec(&mut self, spec: &BirthdaySpec) -> Result<(), Error> { let range = match self.limit_from_until(self.range_with_remind()) { Some(range) => range, diff --git a/src/eval/command/date.rs b/src/eval/command/date.rs index f7ddacb..9a895c2 100644 --- a/src/eval/command/date.rs +++ b/src/eval/command/date.rs @@ -137,7 +137,7 @@ impl DateSpec { } } -impl<'a> CommandState<'a> { +impl CommandState<'_> { pub fn eval_date_spec(&mut self, spec: DateSpec) -> Result<(), Error> { let index = self.source.file(); if let Some(repeat) = &spec.repeat { diff --git a/src/eval/command/formula.rs b/src/eval/command/formula.rs index c9a8692..f50e0d8 100644 --- a/src/eval/command/formula.rs +++ b/src/eval/command/formula.rs @@ -51,38 +51,38 @@ pub enum Var { impl Var { fn eval(self, index: S, date: NaiveDate) -> Result> { Ok(match self { - Var::JulianDay => date.num_days_from_ce().into(), - Var::Year => date.year().into(), - Var::YearLength => util::year_length(date.year()).into(), - Var::YearDay => date.ordinal().into(), - Var::YearDayReverse => (util::year_length(date.year()) - date.ordinal0()).into(), - Var::YearWeek => (date.ordinal0().div_euclid(7) + 1).into(), - Var::YearWeekReverse => { + Self::JulianDay => date.num_days_from_ce().into(), + Self::Year => date.year().into(), + Self::YearLength => util::year_length(date.year()).into(), + Self::YearDay => date.ordinal().into(), + Self::YearDayReverse => (util::year_length(date.year()) - date.ordinal0()).into(), + Self::YearWeek => (date.ordinal0().div_euclid(7) + 1).into(), + Self::YearWeekReverse => { #[allow(non_snake_case)] let yD = util::year_length(date.year()) - date.ordinal(); (yD.div_euclid(7) + 1).into() } - Var::Month => date.month().into(), - Var::MonthLength => util::month_length(date.year(), date.month()).into(), - Var::MonthWeek => (date.day0().div_euclid(7) + 1).into(), - Var::MonthWeekReverse => { + Self::Month => date.month().into(), + Self::MonthLength => util::month_length(date.year(), date.month()).into(), + Self::MonthWeek => (date.day0().div_euclid(7) + 1).into(), + Self::MonthWeekReverse => { #[allow(non_snake_case)] let mD = util::month_length(date.year(), date.month()) - date.day(); (mD.div_euclid(7) + 1).into() } - Var::Day => date.day().into(), - Var::DayReverse => { + Self::Day => date.day().into(), + Self::DayReverse => { let ml = util::month_length(date.year(), date.month()); (ml - date.day0()).into() } - Var::IsoYear => date.iso_week().year().into(), - Var::IsoYearLength => util::iso_year_length(date.iso_week().year()).into(), - Var::IsoWeek => date.iso_week().week().into(), - Var::Weekday => { + Self::IsoYear => date.iso_week().year().into(), + Self::IsoYearLength => util::iso_year_length(date.iso_week().year()).into(), + Self::IsoWeek => date.iso_week().week().into(), + Self::Weekday => { let wd: Weekday = date.weekday().into(); wd.num().into() } - Var::Easter(span) => { + Self::Easter(span) => { let e = computus::gregorian(date.year()).map_err(|e| Error::Easter { index, span, @@ -91,16 +91,16 @@ impl Var { })?; NaiveDate::from_ymd(e.year, e.month, e.day).ordinal().into() } - Var::IsWeekday => { + Self::IsWeekday => { let wd: Weekday = date.weekday().into(); b2i(!wd.is_weekend()) } - Var::IsWeekend => { + Self::IsWeekend => { let wd: Weekday = date.weekday().into(); b2i(wd.is_weekend()) } - Var::IsLeapYear => b2i(util::is_leap_year(date.year())), - Var::IsIsoLeapYear => b2i(util::is_iso_leap_year(date.year())), + Self::IsLeapYear => b2i(util::is_leap_year(date.year())), + Self::IsIsoLeapYear => b2i(util::is_iso_leap_year(date.year())), }) } } @@ -206,13 +206,13 @@ impl From for Expr { impl Expr { fn eval(&self, index: S, date: NaiveDate) -> Result> { Ok(match self { - Expr::Lit(l) => *l, - Expr::Var(v) => v.eval(index, date)?, - Expr::Neg(e) => -e.eval(index, date)?, - Expr::Add(a, b) => a.eval(index, date)? + b.eval(index, date)?, - Expr::Sub(a, b) => a.eval(index, date)? - b.eval(index, date)?, - Expr::Mul(a, b) => a.eval(index, date)? * b.eval(index, date)?, - Expr::Div(a, b, span) => { + Self::Lit(l) => *l, + Self::Var(v) => v.eval(index, date)?, + Self::Neg(e) => -e.eval(index, date)?, + Self::Add(a, b) => a.eval(index, date)? + b.eval(index, date)?, + Self::Sub(a, b) => a.eval(index, date)? - b.eval(index, date)?, + Self::Mul(a, b) => a.eval(index, date)? * b.eval(index, date)?, + Self::Div(a, b, span) => { let b = b.eval(index, date)?; if b == 0 { return Err(Error::DivByZero { @@ -223,7 +223,7 @@ impl Expr { } a.eval(index, date)?.div_euclid(b) } - Expr::Mod(a, b, span) => { + Self::Mod(a, b, span) => { let b = b.eval(index, date)?; if b == 0 { return Err(Error::ModByZero { @@ -234,16 +234,16 @@ impl Expr { } a.eval(index, date)?.rem_euclid(b) } - Expr::Eq(a, b) => b2i(a.eval(index, date)? == b.eval(index, date)?), - Expr::Neq(a, b) => b2i(a.eval(index, date)? != b.eval(index, date)?), - Expr::Lt(a, b) => b2i(a.eval(index, date)? < b.eval(index, date)?), - Expr::Lte(a, b) => b2i(a.eval(index, date)? <= b.eval(index, date)?), - Expr::Gt(a, b) => b2i(a.eval(index, date)? > b.eval(index, date)?), - Expr::Gte(a, b) => b2i(a.eval(index, date)? >= b.eval(index, date)?), - Expr::Not(e) => b2i(!i2b(e.eval(index, date)?)), - Expr::And(a, b) => b2i(i2b(a.eval(index, date)?) && i2b(b.eval(index, date)?)), - Expr::Or(a, b) => b2i(i2b(a.eval(index, date)?) || i2b(b.eval(index, date)?)), - Expr::Xor(a, b) => b2i(i2b(a.eval(index, date)?) ^ i2b(b.eval(index, date)?)), + Self::Eq(a, b) => b2i(a.eval(index, date)? == b.eval(index, date)?), + Self::Neq(a, b) => b2i(a.eval(index, date)? != b.eval(index, date)?), + Self::Lt(a, b) => b2i(a.eval(index, date)? < b.eval(index, date)?), + Self::Lte(a, b) => b2i(a.eval(index, date)? <= b.eval(index, date)?), + Self::Gt(a, b) => b2i(a.eval(index, date)? > b.eval(index, date)?), + Self::Gte(a, b) => b2i(a.eval(index, date)? >= b.eval(index, date)?), + Self::Not(e) => b2i(!i2b(e.eval(index, date)?)), + Self::And(a, b) => b2i(i2b(a.eval(index, date)?) && i2b(b.eval(index, date)?)), + Self::Or(a, b) => b2i(i2b(a.eval(index, date)?) || i2b(b.eval(index, date)?)), + Self::Xor(a, b) => b2i(i2b(a.eval(index, date)?) ^ i2b(b.eval(index, date)?)), }) } } @@ -362,7 +362,7 @@ impl FormulaSpec { } } -impl<'a> CommandState<'a> { +impl CommandState<'_> { pub fn eval_formula_spec(&mut self, spec: FormulaSpec) -> Result<(), Error> { if let Some(range) = spec.range(self) { let index = self.source.file(); diff --git a/src/eval/delta.rs b/src/eval/delta.rs index 364a226..f390cf2 100644 --- a/src/eval/delta.rs +++ b/src/eval/delta.rs @@ -43,84 +43,84 @@ impl DeltaStep { /// A lower bound on days fn lower_bound(&self) -> i32 { match self { - DeltaStep::Year(n) => { + Self::Year(n) => { if *n < 0 { *n * 366 } else { *n * 365 } } - DeltaStep::Month(n) | DeltaStep::MonthReverse(n) => { + Self::Month(n) | Self::MonthReverse(n) => { if *n < 0 { *n * 31 } else { *n * 28 } } - DeltaStep::Day(n) => *n, - DeltaStep::Week(n) => *n * 7, - DeltaStep::Hour(n) => { + Self::Day(n) => *n, + Self::Week(n) => *n * 7, + Self::Hour(n) => { if *n < 0 { *n / 24 + (*n % 24).signum() } else { *n / 24 } } - DeltaStep::Minute(n) => { + Self::Minute(n) => { if *n < 0 { *n / (24 * 60) + (*n % (24 * 60)).signum() } else { *n / (24 * 60) } } - DeltaStep::Weekday(n, _) => match n.cmp(&0) { + Self::Weekday(n, _) => match n.cmp(&0) { Ordering::Less => *n * 7 - 1, Ordering::Equal => 0, Ordering::Greater => *n * 7 - 7, }, - DeltaStep::Time(_) => 0, + Self::Time(_) => 0, } } /// An upper bound on days fn upper_bound(&self) -> i32 { match self { - DeltaStep::Year(n) => { + Self::Year(n) => { if *n > 0 { *n * 366 } else { *n * 365 } } - DeltaStep::Month(n) | DeltaStep::MonthReverse(n) => { + Self::Month(n) | Self::MonthReverse(n) => { if *n > 0 { *n * 31 } else { *n * 28 } } - DeltaStep::Day(n) => *n, - DeltaStep::Week(n) => *n * 7, - DeltaStep::Hour(n) => { + Self::Day(n) => *n, + Self::Week(n) => *n * 7, + Self::Hour(n) => { if *n > 0 { *n / 24 + (*n % 24).signum() } else { *n / 24 } } - DeltaStep::Minute(n) => { + Self::Minute(n) => { if *n > 0 { *n / (24 * 60) + (*n % (24 * 60)).signum() } else { *n / (24 * 60) } } - DeltaStep::Weekday(n, _) => match n.cmp(&0) { + Self::Weekday(n, _) => match n.cmp(&0) { Ordering::Less => *n * 7 - 7, Ordering::Equal => 0, Ordering::Greater => *n * 7 - 1, }, - DeltaStep::Time(_) => 1, + Self::Time(_) => 1, } } } diff --git a/src/files/commands.rs b/src/files/commands.rs index 483fd7a..e3ff9d3 100644 --- a/src/files/commands.rs +++ b/src/files/commands.rs @@ -27,27 +27,27 @@ pub enum DeltaStep { impl DeltaStep { pub fn amount(&self) -> i32 { match self { - DeltaStep::Year(i) => *i, - DeltaStep::Month(i) => *i, - DeltaStep::MonthReverse(i) => *i, - DeltaStep::Day(i) => *i, - DeltaStep::Week(i) => *i, - DeltaStep::Hour(i) => *i, - DeltaStep::Minute(i) => *i, - DeltaStep::Weekday(i, _) => *i, + Self::Year(i) => *i, + Self::Month(i) => *i, + Self::MonthReverse(i) => *i, + Self::Day(i) => *i, + Self::Week(i) => *i, + Self::Hour(i) => *i, + Self::Minute(i) => *i, + Self::Weekday(i, _) => *i, } } pub fn name(&self) -> &'static str { match self { - DeltaStep::Year(_) => "y", - DeltaStep::Month(_) => "m", - DeltaStep::MonthReverse(_) => "M", - DeltaStep::Day(_) => "d", - DeltaStep::Week(_) => "w", - DeltaStep::Hour(_) => "h", - DeltaStep::Minute(_) => "min", - DeltaStep::Weekday(_, wd) => wd.name(), + Self::Year(_) => "y", + Self::Month(_) => "m", + Self::MonthReverse(_) => "M", + Self::Day(_) => "d", + Self::Week(_) => "w", + Self::Hour(_) => "h", + Self::Minute(_) => "min", + Self::Weekday(_, wd) => wd.name(), } } } @@ -168,39 +168,39 @@ impl Var { pub fn name(&self) -> &'static str { match self { // Constants - Var::True => "true", - Var::False => "false", - Var::Monday => "mon", - Var::Tuesday => "tue", - Var::Wednesday => "wed", - Var::Thursday => "thu", - Var::Friday => "fri", - Var::Saturday => "sat", - Var::Sunday => "sun", + Self::True => "true", + Self::False => "false", + Self::Monday => "mon", + Self::Tuesday => "tue", + Self::Wednesday => "wed", + Self::Thursday => "thu", + Self::Friday => "fri", + Self::Saturday => "sat", + Self::Sunday => "sun", // Variables - Var::JulianDay => "j", - Var::Year => "y", - Var::YearLength => "yl", - Var::YearDay => "yd", - Var::YearDayReverse => "yD", - Var::YearWeek => "yw", - Var::YearWeekReverse => "yW", - Var::Month => "m", - Var::MonthLength => "ml", - Var::MonthWeek => "mw", - Var::MonthWeekReverse => "mW", - Var::Day => "d", - Var::DayReverse => "D", - Var::IsoYear => "iy", - Var::IsoYearLength => "iyl", - Var::IsoWeek => "iw", - Var::Weekday => "wd", - Var::Easter => "e", + Self::JulianDay => "j", + Self::Year => "y", + Self::YearLength => "yl", + Self::YearDay => "yd", + Self::YearDayReverse => "yD", + Self::YearWeek => "yw", + Self::YearWeekReverse => "yW", + Self::Month => "m", + Self::MonthLength => "ml", + Self::MonthWeek => "mw", + Self::MonthWeekReverse => "mW", + Self::Day => "d", + Self::DayReverse => "D", + Self::IsoYear => "iy", + Self::IsoYearLength => "iyl", + Self::IsoWeek => "iw", + Self::Weekday => "wd", + Self::Easter => "e", // Variables with "boolean" values - Var::IsWeekday => "isWeekday", - Var::IsWeekend => "isWeekend", - Var::IsLeapYear => "isLeapYear", - Var::IsIsoLeapYear => "isIsoLeapYear", + Self::IsWeekday => "isWeekday", + Self::IsWeekend => "isWeekend", + Self::IsLeapYear => "isLeapYear", + Self::IsIsoLeapYear => "isIsoLeapYear", } } } @@ -301,11 +301,11 @@ pub enum DoneDate { impl DoneDate { pub fn root(self) -> NaiveDate { match self { - DoneDate::Date { root } => root, - DoneDate::DateTime { root, .. } => root, - DoneDate::DateToDate { root, .. } => root, - DoneDate::DateTimeToTime { root, .. } => root, - DoneDate::DateTimeToDateTime { root, .. } => root, + Self::Date { root } => root, + Self::DateTime { root, .. } => root, + Self::DateToDate { root, .. } => root, + Self::DateTimeToTime { root, .. } => root, + Self::DateTimeToDateTime { root, .. } => root, } } diff --git a/src/files/error.rs b/src/files/error.rs index f0ad33e..40fa7f7 100644 --- a/src/files/error.rs +++ b/src/files/error.rs @@ -134,19 +134,19 @@ pub enum Error { impl<'a> Eprint<'a, Files> for Error { fn eprint<'f: 'a>(&self, files: &'f Files, config: &Config) { match self { - Error::ResolvePath { path, error } => { + Self::ResolvePath { path, error } => { eprintln!("Could not resolve path {path:?}:"); eprintln!(" {error}"); } - Error::ReadFile { file, error } => { + Self::ReadFile { file, error } => { eprintln!("Could not read file {file:?}:"); eprintln!(" {error}"); } - Error::WriteFile { file, error } => { + Self::WriteFile { file, error } => { eprintln!("Could not write file {file:?}:"); eprintln!(" {error}"); } - Error::ResolveTz { + Self::ResolveTz { file, span, tz, @@ -158,14 +158,14 @@ impl<'a> Eprint<'a, Files> for Error { .with_notes(vec![format!("{error}")]); Self::eprint_diagnostic(files, config, &diagnostic); } - Error::LocalTz { error } => { + Self::LocalTz { error } => { eprintln!("Could not determine local timezone:"); eprintln!(" {error}"); } - Error::Parse { file, error } => { + Self::Parse { file, error } => { ParseError::new(*file, error.clone()).eprint(files, config) } - Error::TzConflict { + Self::TzConflict { file1, span1, tz1, @@ -184,7 +184,7 @@ impl<'a> Eprint<'a, Files> for Error { ]); Self::eprint_diagnostic(files, config, &diagnostic); } - Error::MultipleCapture { + Self::MultipleCapture { file1, span1, file2, @@ -201,7 +201,7 @@ impl<'a> Eprint<'a, Files> for Error { ]); Self::eprint_diagnostic(files, config, &diagnostic); } - Error::LogConflict { + Self::LogConflict { file1, span1, file2, diff --git a/src/files/format.rs b/src/files/format.rs index caa5d9b..280d58c 100644 --- a/src/files/format.rs +++ b/src/files/format.rs @@ -140,25 +140,25 @@ impl fmt::Display for Var { impl fmt::Display for Expr { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Expr::Lit(i) => write!(f, "{i}"), - Expr::Var(v) => write!(f, "{v}"), - Expr::Paren(e) => write!(f, "({e})"), - Expr::Neg(e) => write!(f, "-{e}"), - Expr::Add(a, b) => write!(f, "{a} + {b}"), - Expr::Sub(a, b) => write!(f, "{a} - {b}"), - Expr::Mul(a, b) => write!(f, "{a} * {b}"), - Expr::Div(a, b) => write!(f, "{a} / {b}"), - Expr::Mod(a, b) => write!(f, "{a} % {b}"), - Expr::Eq(a, b) => write!(f, "{a} = {b}"), - Expr::Neq(a, b) => write!(f, "{a} != {b}"), - Expr::Lt(a, b) => write!(f, "{a} < {b}"), - Expr::Lte(a, b) => write!(f, "{a} <= {b}"), - Expr::Gt(a, b) => write!(f, "{a} > {b}"), - Expr::Gte(a, b) => write!(f, "{a} >= {b}"), - Expr::Not(e) => write!(f, "!{e}"), - Expr::And(a, b) => write!(f, "{a} & {b}"), - Expr::Or(a, b) => write!(f, "{a} | {b}"), - Expr::Xor(a, b) => write!(f, "{a} ^ {b}"), + Self::Lit(i) => write!(f, "{i}"), + Self::Var(v) => write!(f, "{v}"), + Self::Paren(e) => write!(f, "({e})"), + Self::Neg(e) => write!(f, "-{e}"), + Self::Add(a, b) => write!(f, "{a} + {b}"), + Self::Sub(a, b) => write!(f, "{a} - {b}"), + Self::Mul(a, b) => write!(f, "{a} * {b}"), + Self::Div(a, b) => write!(f, "{a} / {b}"), + Self::Mod(a, b) => write!(f, "{a} % {b}"), + Self::Eq(a, b) => write!(f, "{a} = {b}"), + Self::Neq(a, b) => write!(f, "{a} != {b}"), + Self::Lt(a, b) => write!(f, "{a} < {b}"), + Self::Lte(a, b) => write!(f, "{a} <= {b}"), + Self::Gt(a, b) => write!(f, "{a} > {b}"), + Self::Gte(a, b) => write!(f, "{a} >= {b}"), + Self::Not(e) => write!(f, "!{e}"), + Self::And(a, b) => write!(f, "{a} & {b}"), + Self::Or(a, b) => write!(f, "{a} | {b}"), + Self::Xor(a, b) => write!(f, "{a} ^ {b}"), } } } @@ -196,9 +196,9 @@ impl fmt::Display for FormulaSpec { impl fmt::Display for Spec { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Spec::Date(spec) => write!(f, "{spec}"), - Spec::Weekday(spec) => write!(f, "{spec}"), - Spec::Formula(spec) => write!(f, "{spec}"), + Self::Date(spec) => write!(f, "{spec}"), + Self::Weekday(spec) => write!(f, "{spec}"), + Self::Formula(spec) => write!(f, "{spec}"), } } } @@ -216,14 +216,14 @@ impl fmt::Display for BirthdaySpec { impl fmt::Display for Statement { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Statement::Date(spec) => writeln!(f, "DATE {spec}"), - Statement::BDate(spec) => writeln!(f, "BDATE {spec}"), - Statement::From(Some(date)) => writeln!(f, "FROM {date}"), - Statement::From(None) => writeln!(f, "FROM *"), - Statement::Until(Some(date)) => writeln!(f, "UNTIL {date}"), - Statement::Until(None) => writeln!(f, "UNTIL *"), - Statement::Except(date) => writeln!(f, "EXCEPT {date}"), - Statement::Move { + Self::Date(spec) => writeln!(f, "DATE {spec}"), + Self::BDate(spec) => writeln!(f, "BDATE {spec}"), + Self::From(Some(date)) => writeln!(f, "FROM {date}"), + Self::From(None) => writeln!(f, "FROM *"), + Self::Until(Some(date)) => writeln!(f, "UNTIL {date}"), + Self::Until(None) => writeln!(f, "UNTIL *"), + Self::Except(date) => writeln!(f, "EXCEPT {date}"), + Self::Move { from, to, to_time, .. } => match (to, to_time) { (None, None) => unreachable!(), @@ -231,8 +231,8 @@ impl fmt::Display for Statement { (None, Some(to_time)) => writeln!(f, "MOVE {from} TO {to_time}"), (Some(to), Some(to_time)) => writeln!(f, "MOVE {from} TO {to} {to_time}"), }, - Statement::Remind(Some(delta)) => writeln!(f, "REMIND {delta}"), - Statement::Remind(None) => writeln!(f, "REMIND *"), + Self::Remind(Some(delta)) => writeln!(f, "REMIND {delta}"), + Self::Remind(None) => writeln!(f, "REMIND *"), } } } @@ -240,15 +240,15 @@ impl fmt::Display for Statement { impl fmt::Display for DoneDate { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.simplified() { - DoneDate::Date { root } => write!(f, "{root}"), - DoneDate::DateTime { root, root_time } => write!(f, "{root} {root_time}"), - DoneDate::DateToDate { root, other } => write!(f, "{root} -- {other}"), - DoneDate::DateTimeToTime { + Self::Date { root } => write!(f, "{root}"), + Self::DateTime { root, root_time } => write!(f, "{root} {root_time}"), + Self::DateToDate { root, other } => write!(f, "{root} -- {other}"), + Self::DateTimeToTime { root, root_time, other_time, } => write!(f, "{root} {root_time} -- {other_time}"), - DoneDate::DateTimeToDateTime { + Self::DateTimeToDateTime { root, root_time, other, @@ -308,12 +308,12 @@ impl fmt::Display for Log { impl fmt::Display for Command { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Command::Include(name) => writeln!(f, "INCLUDE {name}"), - Command::Timezone(name) => writeln!(f, "TIMEZONE {name}"), - Command::Capture => writeln!(f, "CAPTURE"), - Command::Task(task) => write!(f, "{task}"), - Command::Note(note) => write!(f, "{note}"), - Command::Log(log) => write!(f, "{log}"), + Self::Include(name) => writeln!(f, "INCLUDE {name}"), + Self::Timezone(name) => writeln!(f, "TIMEZONE {name}"), + Self::Capture => writeln!(f, "CAPTURE"), + Self::Task(task) => write!(f, "{task}"), + Self::Note(note) => write!(f, "{note}"), + Self::Log(log) => write!(f, "{log}"), } } } diff --git a/src/files/primitives.rs b/src/files/primitives.rs index e63b867..b4a9dc2 100644 --- a/src/files/primitives.rs +++ b/src/files/primitives.rs @@ -206,13 +206,13 @@ impl Weekday { /// `Saturday`, `Sunday`). pub fn full_name(self) -> &'static str { match self { - Weekday::Monday => "Monday", - Weekday::Tuesday => "Tuesday", - Weekday::Wednesday => "Wednesday", - Weekday::Thursday => "Thursday", - Weekday::Friday => "Friday", - Weekday::Saturday => "Saturday", - Weekday::Sunday => "Sunday", + Self::Monday => "Monday", + Self::Tuesday => "Tuesday", + Self::Wednesday => "Wednesday", + Self::Thursday => "Thursday", + Self::Friday => "Friday", + Self::Saturday => "Saturday", + Self::Sunday => "Sunday", } }