mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-04 19:12:50 +00:00
Reduce code size of assert_matches_failed
This commit is contained in:
parent
a1bea1551b
commit
289d7cca1d
@ -190,11 +190,11 @@ pub fn assert_matches_failed<T: fmt::Debug + ?Sized>(
|
|||||||
right: &str,
|
right: &str,
|
||||||
args: Option<fmt::Arguments<'_>>,
|
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);
|
struct Pattern<'a>(&'a str);
|
||||||
impl fmt::Debug for Pattern<'_> {
|
impl fmt::Debug for Pattern<'_> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
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);
|
assert_failed_inner(AssertKind::Match, &left, &Pattern(right), args);
|
||||||
|
Loading…
Reference in New Issue
Block a user