Skip to content

Commit

Permalink
Remove deprecated description
Browse files Browse the repository at this point in the history
  • Loading branch information
kornelski authored and seanmonstar committed Dec 16, 2019
1 parent 65ea9c3 commit d5c0360
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
18 changes: 8 additions & 10 deletions mime-parse/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,24 +86,22 @@ impl fmt::Debug for Byte {
}

impl Error for ParseError {
fn description(&self) -> &str {
match self {
}

impl fmt::Display for ParseError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let description = match self {
ParseError::MissingSlash => "a slash (/) was missing between the type and subtype",
ParseError::MissingEqual => "an equals sign (=) was missing between a parameter and its value",
ParseError::MissingQuote => "a quote (\") was missing from a parameter value",
ParseError::InvalidToken { .. } => "invalid token",
ParseError::InvalidRange => "unexpected asterisk",
ParseError::TooLong => "the string is too long",
}
}
}

impl fmt::Display for ParseError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
};
if let ParseError::InvalidToken { pos, byte } = *self {
write!(f, "{}, {:?} at position {}", self.description(), byte, pos)
write!(f, "{}, {:?} at position {}", description, byte, pos)
} else {
f.write_str(self.description())
f.write_str(description)
}
}
}
Expand Down
5 changes: 1 addition & 4 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@ pub struct InvalidMime {
}

impl Error for InvalidMime {
fn description(&self) -> &str {
"invalid MIME"
}
}

impl fmt::Display for InvalidMime {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}: {}", self.description(), self.inner)
write!(f, "invalid MIME: {}", self.inner)
}
}

0 comments on commit d5c0360

Please sign in to comment.