diff options
| author | Federico Mena Quintero <federico@gnome.org> | 2016-12-08 14:54:04 -0600 |
|---|---|---|
| committer | Federico Mena Quintero <federico@gnome.org> | 2017-01-11 18:10:26 -0600 |
| commit | ff5ba731a0f19df98e8211772f41ad3c3216089f (patch) | |
| tree | d319aa94b58dc094df82d24da64be22503e6d216 | |
| parent | b27c7095606ad9386a7038d7af03abd7f948f02f (diff) | |
| download | rust-ff5ba731a0f19df98e8211772f41ad3c3216089f.tar.gz rust-ff5ba731a0f19df98e8211772f41ad3c3216089f.zip | |
Document the optional extra arguments to assert_eq!() / assert_ne!()
And clarify that those arguments in assert!() are in fact formattable.
| -rw-r--r-- | src/libcore/macros.rs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs index ba52edb1ae8..bc5392f6b88 100644 --- a/src/libcore/macros.rs +++ b/src/libcore/macros.rs @@ -45,7 +45,8 @@ macro_rules! panic { /// Other use-cases of `assert!` include [testing] and enforcing run-time /// 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 /// @@ -87,12 +88,17 @@ macro_rules! assert { /// On panic, this macro will print the values of the expressions with their /// debug representations. /// +/// Like `assert!()`, this macro has a second version, where a custom +/// panic message can be provided. +/// /// # Examples /// /// ``` /// let a = 3; /// let b = 1 + 2; /// assert_eq!(a, b); +/// +/// assert_eq!(a, b, "we are testing addition with {} and {}", a, b); /// ``` #[macro_export] #[stable(feature = "rust1", since = "1.0.0")] @@ -125,12 +131,17 @@ macro_rules! assert_eq { /// On panic, this macro will print the values of the expressions with their /// debug representations. /// +/// Like `assert!()`, this macro has a second version, where a custom +/// panic message can be provided. +/// /// # Examples /// /// ``` /// let a = 3; /// let b = 2; /// assert_ne!(a, b); +/// +/// assert_ne!(a, b, "we are testing that the values are not equal"); /// ``` #[macro_export] #[stable(feature = "assert_ne", since = "1.12.0")] |
