@@ -44,12 +44,20 @@ macro_rules! assert_eq {
44
44
match ( & $left, & $right) {
45
45
( left_val, right_val) => {
46
46
if !( * left_val == * right_val) {
47
+ let left = stringify!( $left) ;
48
+ let right = stringify!( $right) ;
49
+ let width = if left. len( ) > right. len( ) {
50
+ left. len( )
51
+ } else {
52
+ right. len( )
53
+ } ;
54
+
47
55
// The reborrows below are intentional. Without them, the stack slot for the
48
56
// borrow is initialized even before the values are compared, leading to a
49
57
// noticeable slow down.
50
- panic!( r#"assertion failed: `(left == right)`
51
- left: `{:?}`,
52
- right: `{:?}`"#, & * left_val, & * right_val)
58
+ panic!( r#"assertion failed: `({ left}) == ({ right} )`
59
+ { left:>width$} : `{:?}`,
60
+ { right:>width$}: `{:?}`"#, & * left_val, & * right_val, left=left , right=right , width=width )
53
61
}
54
62
}
55
63
}
@@ -61,13 +69,22 @@ macro_rules! assert_eq {
61
69
match ( & ( $left) , & ( $right) ) {
62
70
( left_val, right_val) => {
63
71
if !( * left_val == * right_val) {
72
+ let left = stringify!( $left) ;
73
+ let right = stringify!( $right) ;
74
+ let width = if left. len( ) > right. len( ) {
75
+ left. len( )
76
+ } else {
77
+ right. len( )
78
+ } ;
79
+
64
80
// The reborrows below are intentional. Without them, the stack slot for the
65
81
// borrow is initialized even before the values are compared, leading to a
66
82
// noticeable slow down.
67
- panic!( r#"assertion failed: `(left == right)`
68
- left: `{:?}`,
69
- right: `{:?}`: {}"# , & * left_val, & * right_val,
70
- $crate:: format_args!( $( $arg) +) )
83
+ panic!( r#"assertion failed: `({left}) == ({right})`
84
+ {left:>width$}: `{:?}`,
85
+ {right:>width$}: `{:?}`: {}"# , & * left_val, & * right_val,
86
+ $crate:: format_args!( $( $arg) +) ,
87
+ left=left, right=right, width=width)
71
88
}
72
89
}
73
90
}
@@ -101,12 +118,20 @@ macro_rules! assert_ne {
101
118
match ( & $left, & $right) {
102
119
( left_val, right_val) => {
103
120
if * left_val == * right_val {
121
+ let left = stringify!( $left) ;
122
+ let right = stringify!( $right) ;
123
+ let width = if left. len( ) > right. len( ) {
124
+ left. len( )
125
+ } else {
126
+ right. len( )
127
+ } ;
128
+
104
129
// The reborrows below are intentional. Without them, the stack slot for the
105
130
// borrow is initialized even before the values are compared, leading to a
106
131
// noticeable slow down.
107
- panic!( r#"assertion failed: `(left != right)`
108
- left: `{:?}`,
109
- right: `{:?}`"#, & * left_val, & * right_val)
132
+ panic!( r#"assertion failed: `({ left}) != ({ right} )`
133
+ { left:>width$} : `{:?}`,
134
+ { right:>width$}: `{:?}`"#, & * left_val, & * right_val, left=left , right=right , width=width )
110
135
}
111
136
}
112
137
}
@@ -118,13 +143,22 @@ macro_rules! assert_ne {
118
143
match ( & ( $left) , & ( $right) ) {
119
144
( left_val, right_val) => {
120
145
if * left_val == * right_val {
146
+ let left = stringify!( $left) ;
147
+ let right = stringify!( $right) ;
148
+ let width = if left. len( ) > right. len( ) {
149
+ left. len( )
150
+ } else {
151
+ right. len( )
152
+ } ;
153
+
121
154
// The reborrows below are intentional. Without them, the stack slot for the
122
155
// borrow is initialized even before the values are compared, leading to a
123
156
// noticeable slow down.
124
- panic!( r#"assertion failed: `(left != right)`
125
- left: `{:?}`,
126
- right: `{:?}`: {}"# , & * left_val, & * right_val,
127
- $crate:: format_args!( $( $arg) +) )
157
+ panic!( r#"assertion failed: `({left}) != ({right})`
158
+ {left:>width$}: `{:?}`,
159
+ {right:>width$}: `{:?}`: {}"# , & * left_val, & * right_val,
160
+ $crate:: format_args!( $( $arg) +) ,
161
+ left=left, right=right, width=width)
128
162
}
129
163
}
130
164
}
0 commit comments