diff --git a/src/line.rs b/src/line.rs index 9308c22..b023c83 100644 --- a/src/line.rs +++ b/src/line.rs @@ -510,7 +510,7 @@ impl FromStr for MonthSpec { type Err = Error; /// Attempts to parse the given string into a value of this type. - fn from_str(input: &str) -> Result { + fn from_str(input: &str) -> Result { Ok(match &*input.to_ascii_lowercase() { "jan" | "january" => MonthSpec(Month::January), "feb" | "february" => MonthSpec(Month::February), @@ -538,7 +538,7 @@ pub struct WeekdaySpec(pub Weekday); impl FromStr for WeekdaySpec { type Err = Error; - fn from_str(input: &str) -> Result { + fn from_str(input: &str) -> Result { Ok(match &*input.to_ascii_lowercase() { "mon" | "monday" => WeekdaySpec(Weekday::Monday), @@ -609,7 +609,7 @@ impl DaySpec { impl FromStr for DaySpec { type Err = Error; - fn from_str(input: &str) -> Result { + fn from_str(input: &str) -> Result { // Parse the field as a number if it vaguely resembles one. if input.chars().all(|c| c.is_digit(10)) { @@ -694,7 +694,7 @@ impl TimeSpec { impl FromStr for TimeSpecAndType { type Err = Error; - fn from_str(input: &str) -> Result { + fn from_str(input: &str) -> Result { if input == "-" { Ok(TimeSpecAndType(TimeSpec::Zero, TimeType::Wall)) } @@ -729,7 +729,7 @@ impl FromStr for TimeSpecAndType { impl FromStr for TimeSpec { type Err = Error; - fn from_str(input: &str) -> Result { + fn from_str(input: &str) -> Result { match input.parse() { Ok(TimeSpecAndType(spec, TimeType::Wall)) => Ok(spec), Ok(TimeSpecAndType(_ , _ )) => Err(Error::Fail), diff --git a/src/table.rs b/src/table.rs index 57de001..109f353 100644 --- a/src/table.rs +++ b/src/table.rs @@ -112,8 +112,8 @@ pub struct RuleInfo { } impl<'line> From> for RuleInfo { - fn from(info: line::Rule) -> RuleInfo { - RuleInfo { + fn from(info: line::Rule) -> Self { + Self { from_year: info.from_year, to_year: info.to_year, month: info.month, @@ -184,8 +184,8 @@ pub struct ZoneInfo { } impl<'line> From> for ZoneInfo { - fn from(info: line::ZoneInfo) -> ZoneInfo { - ZoneInfo { + fn from(info: line::ZoneInfo) -> Self { + Self { offset: info.utc_offset.as_seconds(), saving: match info.saving { line::Saving::NoSaving => Saving::NoSaving, @@ -250,7 +250,7 @@ impl Format { /// Convert the template into one of the `Format` variants. This can’t /// fail, as any syntax that doesn’t match one of the two formats will /// just be a ‘constant’ format. - pub fn new(template: &str) -> Format { + pub fn new(template: &str) -> Self { if let Some(pos) = template.find('/') { Format::Alternate { standard: template[.. pos].to_owned(), @@ -306,8 +306,8 @@ pub struct TableBuilder { impl TableBuilder { /// Creates a new builder with an empty table. - pub fn new() -> TableBuilder { - TableBuilder { + pub fn new() -> Self { + Self { table: Table::default(), current_zoneset_name: None, }