Skip to content

Commit

Permalink
remove dummy field from ParseWeedayError and ParseMonthError
Browse files Browse the repository at this point in the history
impl Error trait for ParseMonthError
  • Loading branch information
mike-kfed committed Jul 19, 2023
1 parent 5255fc9 commit 050f051
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/format/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ impl FromStr for Weekday {
if let Ok(("", w)) = scan::short_or_long_weekday(s) {
Ok(w)
} else {
Err(ParseWeekdayError { _dummy: () })
Err(ParseWeekdayError {})
}
}
}
Expand Down Expand Up @@ -531,10 +531,10 @@ impl FromStr for Month {
9 => Ok(Month::October),
10 => Ok(Month::November),
11 => Ok(Month::December),
_ => Err(ParseMonthError { _dummy: () }),
_ => Err(ParseMonthError {}),
}
} else {
Err(ParseMonthError { _dummy: () })
Err(ParseMonthError {})
}
}
}
12 changes: 10 additions & 2 deletions src/month.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,16 @@ impl Months {

/// An error resulting from reading `<Month>` value with `FromStr`.
#[derive(Clone, PartialEq, Eq)]
pub struct ParseMonthError {
pub(crate) _dummy: (),
pub struct ParseMonthError {}

#[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl std::error::Error for ParseMonthError {}

impl fmt::Display for ParseMonthError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "ParseMonthError {{ .. }}")
}
}

impl fmt::Debug for ParseMonthError {
Expand Down
4 changes: 1 addition & 3 deletions src/weekday.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,7 @@ impl num_traits::FromPrimitive for Weekday {

/// An error resulting from reading `Weekday` value with `FromStr`.
#[derive(Clone, PartialEq, Eq)]
pub struct ParseWeekdayError {
pub(crate) _dummy: (),
}
pub struct ParseWeekdayError {}

#[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
Expand Down

0 comments on commit 050f051

Please sign in to comment.