Skip to content

Commit

Permalink
Merge pull request #62 from artichoke/error-write-str
Browse files Browse the repository at this point in the history
Avoid write! macro in fmt::Display impl for DecodeError
  • Loading branch information
lopopolo authored Dec 20, 2020
2 parents 33e67ae + 2273789 commit fbe90c3
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,17 +157,17 @@ impl std::error::Error for DecodeError {}
impl fmt::Display for DecodeError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::ChecksumMismatch => write!(f, "Checksum mismatch"),
Self::Corrupted => write!(f, "Corrupted input"),
Self::ExpectedConsonant => write!(f, "Expected consonant, got something else"),
Self::ExpectedVowel => write!(f, "Expected vowel, got something else"),
Self::ChecksumMismatch => f.write_str("Checksum mismatch"),
Self::Corrupted => f.write_str("Corrupted input"),
Self::ExpectedConsonant => f.write_str("Expected consonant, got something else"),
Self::ExpectedVowel => f.write_str("Expected vowel, got something else"),
Self::InvalidByte(pos) => write!(
f,
"Encountered byte outside of encoding alphabet at position {}",
pos
),
Self::MalformedHeader => write!(f, "Missing required 'x' header"),
Self::MalformedTrailer => write!(f, "Missing required 'x' trailer"),
Self::MalformedHeader => f.write_str("Missing required 'x' header"),
Self::MalformedTrailer => f.write_str("Missing required 'x' trailer"),
}
}
}
Expand Down

0 comments on commit fbe90c3

Please sign in to comment.