Skip to content

Commit

Permalink
Use Self in a couple of places
Browse files Browse the repository at this point in the history
  • Loading branch information
ogham committed Apr 7, 2020
1 parent 17c7dba commit 31bf6b1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions src/line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<MonthSpec, Self::Err> {
fn from_str(input: &str) -> Result<Self, Self::Err> {
Ok(match &*input.to_ascii_lowercase() {
"jan" | "january" => MonthSpec(Month::January),
"feb" | "february" => MonthSpec(Month::February),
Expand Down Expand Up @@ -538,7 +538,7 @@ pub struct WeekdaySpec(pub Weekday);
impl FromStr for WeekdaySpec {
type Err = Error;

fn from_str(input: &str) -> Result<WeekdaySpec, Self::Err> {
fn from_str(input: &str) -> Result<Self, Self::Err> {

Ok(match &*input.to_ascii_lowercase() {
"mon" | "monday" => WeekdaySpec(Weekday::Monday),
Expand Down Expand Up @@ -609,7 +609,7 @@ impl DaySpec {
impl FromStr for DaySpec {
type Err = Error;

fn from_str(input: &str) -> Result<DaySpec, Self::Err> {
fn from_str(input: &str) -> Result<Self, Self::Err> {

// Parse the field as a number if it vaguely resembles one.
if input.chars().all(|c| c.is_digit(10)) {
Expand Down Expand Up @@ -694,7 +694,7 @@ impl TimeSpec {
impl FromStr for TimeSpecAndType {
type Err = Error;

fn from_str(input: &str) -> Result<TimeSpecAndType, Self::Err> {
fn from_str(input: &str) -> Result<Self, Self::Err> {
if input == "-" {
Ok(TimeSpecAndType(TimeSpec::Zero, TimeType::Wall))
}
Expand Down Expand Up @@ -729,7 +729,7 @@ impl FromStr for TimeSpecAndType {
impl FromStr for TimeSpec {
type Err = Error;

fn from_str(input: &str) -> Result<TimeSpec, Self::Err> {
fn from_str(input: &str) -> Result<Self, Self::Err> {
match input.parse() {
Ok(TimeSpecAndType(spec, TimeType::Wall)) => Ok(spec),
Ok(TimeSpecAndType(_ , _ )) => Err(Error::Fail),
Expand Down
14 changes: 7 additions & 7 deletions src/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ pub struct RuleInfo {
}

impl<'line> From<line::Rule<'line>> 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,
Expand Down Expand Up @@ -184,8 +184,8 @@ pub struct ZoneInfo {
}

impl<'line> From<line::ZoneInfo<'line>> 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,
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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,
}
Expand Down

0 comments on commit 31bf6b1

Please sign in to comment.