@@ -45,7 +45,8 @@ macro_rules! panic {
45
45
/// Other use-cases of `assert!` include [testing] and enforcing run-time
46
46
/// invariants in safe code (whose violation cannot result in unsafety).
47
47
///
48
- /// This macro has a second version, where a custom panic message can be provided.
48
+ /// This macro has a second version, where a custom panic message can
49
+ /// be provided with or without arguments for formatting.
49
50
///
50
51
/// [testing]: ../book/testing.html
51
52
///
@@ -87,12 +88,17 @@ macro_rules! assert {
87
88
/// On panic, this macro will print the values of the expressions with their
88
89
/// debug representations.
89
90
///
91
+ /// Like `assert!()`, this macro has a second version, where a custom
92
+ /// panic message can be provided.
93
+ ///
90
94
/// # Examples
91
95
///
92
96
/// ```
93
97
/// let a = 3;
94
98
/// let b = 1 + 2;
95
99
/// assert_eq!(a, b);
100
+ ///
101
+ /// assert_eq!(a, b, "we are testing addition with {} and {}", a, b);
96
102
/// ```
97
103
#[ macro_export]
98
104
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -125,12 +131,17 @@ macro_rules! assert_eq {
125
131
/// On panic, this macro will print the values of the expressions with their
126
132
/// debug representations.
127
133
///
134
+ /// Like `assert!()`, this macro has a second version, where a custom
135
+ /// panic message can be provided.
136
+ ///
128
137
/// # Examples
129
138
///
130
139
/// ```
131
140
/// let a = 3;
132
141
/// let b = 2;
133
142
/// assert_ne!(a, b);
143
+ ///
144
+ /// assert_ne!(a, b, "we are testing that the values are not equal");
134
145
/// ```
135
146
#[ macro_export]
136
147
#[ stable( feature = "assert_ne" , since = "1.12.0" ) ]
0 commit comments