Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 17, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/libcore/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
Expand Down Expand Up @@ -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")]
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
/// 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")]
Expand Down