Skip to content

Commit

Permalink
Reduce code size of assert_matches_failed
Browse files Browse the repository at this point in the history
  • Loading branch information
a1phyr committed Aug 23, 2022
1 parent a1bea15 commit 289d7cc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions library/core/src/panicking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,11 @@ pub fn assert_matches_failed<T: fmt::Debug + ?Sized>(
right: &str,
args: Option<fmt::Arguments<'_>>,
) -> ! {
// Use the Display implementation to display the pattern.
// The pattern is a string so it can be displayed directly.
struct Pattern<'a>(&'a str);
impl fmt::Debug for Pattern<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Display::fmt(self.0, f)
f.write_str(self.0)
}
}
assert_failed_inner(AssertKind::Match, &left, &Pattern(right), args);
Expand Down

0 comments on commit 289d7cc

Please sign in to comment.