Skip to content

Commit

Permalink
Rollup merge of #38247 - federicomenaquintero:assert-eq-argument-docs…
Browse files Browse the repository at this point in the history
…, r=GuillaumeGomez

Document the optional extra arguments to assert_eq!() / assert_ne!()

And clarify that those arguments in assert!() are in fact formattable.
  • Loading branch information
GuillaumeGomez committed Jan 16, 2017
2 parents 2d0baa7 + ff5ba73 commit 1293b79
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/libcore/macros.rs
Expand Up @@ -45,7 +45,8 @@ macro_rules! panic {
/// Other use-cases of `assert!` include [testing] and enforcing run-time /// Other use-cases of `assert!` include [testing] and enforcing run-time
/// invariants in safe code (whose violation cannot result in unsafety). /// invariants in safe code (whose violation cannot result in unsafety).
/// ///
/// This macro has a second version, where a custom panic message can be provided. /// This macro has a second version, where a custom panic message can
/// be provided with or without arguments for formatting.
/// ///
/// [testing]: ../book/testing.html /// [testing]: ../book/testing.html
/// ///
Expand Down Expand Up @@ -87,12 +88,17 @@ macro_rules! assert {
/// On panic, this macro will print the values of the expressions with their /// On panic, this macro will print the values of the expressions with their
/// debug representations. /// debug representations.
/// ///
/// Like `assert!()`, this macro has a second version, where a custom
/// panic message can be provided.
///
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// let a = 3; /// let a = 3;
/// let b = 1 + 2; /// let b = 1 + 2;
/// assert_eq!(a, b); /// assert_eq!(a, b);
///
/// assert_eq!(a, b, "we are testing addition with {} and {}", a, b);
/// ``` /// ```
#[macro_export] #[macro_export]
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
Expand Down Expand Up @@ -125,12 +131,17 @@ macro_rules! assert_eq {
/// On panic, this macro will print the values of the expressions with their /// On panic, this macro will print the values of the expressions with their
/// debug representations. /// debug representations.
/// ///
/// Like `assert!()`, this macro has a second version, where a custom
/// panic message can be provided.
///
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// let a = 3; /// let a = 3;
/// let b = 2; /// let b = 2;
/// assert_ne!(a, b); /// assert_ne!(a, b);
///
/// assert_ne!(a, b, "we are testing that the values are not equal");
/// ``` /// ```
#[macro_export] #[macro_export]
#[stable(feature = "assert_ne", since = "1.12.0")] #[stable(feature = "assert_ne", since = "1.12.0")]
Expand Down

0 comments on commit 1293b79

Please sign in to comment.