]> git.lizzy.rs Git - rust.git/blobdiff - src/libcore/macros.rs
Removing tabs. Sorry - have updated my .vimrc
[rust.git] / src / libcore / macros.rs
index 2a28d108df77d168332424977fe3328b73d0fdd2..326b5281d9e8f992fbb24a7bbd48881a956b29fb 100644 (file)
@@ -35,6 +35,8 @@ macro_rules! panic {
 /// This will invoke the [`panic!`] macro if the provided expression cannot be
 /// evaluated to `true` at runtime.
 ///
+/// # Uses
+///
 /// Assertions are always checked in both debug and release builds, and cannot
 /// be disabled. See [`debug_assert!`] for assertions that are not enabled in
 /// release builds by default.
@@ -45,7 +47,9 @@ 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
+/// # Custom Messages
+///
+/// This macro has a second form, where a custom panic message can
 /// be provided with or without arguments for formatting.
 ///
 /// [`panic!`]: macro.panic.html
@@ -85,14 +89,15 @@ macro_rules! assert {
     );
 }
 
-/// Asserts that two expressions are equal to each other.
+/// Asserts that two expressions are equal to each other (using [`PartialEq`]).
 ///
 /// 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
+/// Like [`assert!`], this macro has a second form, where a custom
 /// panic message can be provided.
 ///
+/// [`PartialEq`]: cmp/trait.PartialEq.html
 /// [`assert!`]: macro.assert.html
 ///
 /// # Examples
@@ -111,8 +116,9 @@ macro_rules! assert_eq {
         match (&$left, &$right) {
             (left_val, right_val) => {
                 if !(*left_val == *right_val) {
-                    panic!("assertion failed: `(left == right)` \
-                           (left: `{:?}`, right: `{:?}`)", left_val, right_val)
+                    panic!(r#"assertion failed: `(left == right)`
+  left: `{:?}`
+ right: `{:?}`"#, left_val, right_val)
                 }
             }
         }
@@ -121,8 +127,9 @@ macro_rules! assert_eq {
         match (&($left), &($right)) {
             (left_val, right_val) => {
                 if !(*left_val == *right_val) {
-                    panic!("assertion failed: `(left == right)` \
-                           (left: `{:?}`, right: `{:?}`): {}", left_val, right_val,
+                    panic!(r#"assertion failed: `(left == right)`
+  left: `{:?}`
+ right: `{:?}`: {}"#, left_val, right_val,
                            format_args!($($arg)+))
                 }
             }
@@ -130,14 +137,15 @@ macro_rules! assert_eq {
     });
 }
 
-/// Asserts that two expressions are not equal to each other.
+/// Asserts that two expressions are not equal to each other (using [`PartialEq`]).
 ///
 /// 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
+/// Like [`assert!`], this macro has a second form, where a custom
 /// panic message can be provided.
 ///
+/// [`PartialEq`]: cmp/trait.PartialEq.html
 /// [`assert!`]: macro.assert.html
 ///
 /// # Examples
@@ -150,14 +158,15 @@ macro_rules! assert_eq {
 /// assert_ne!(a, b, "we are testing that the values are not equal");
 /// ```
 #[macro_export]
-#[stable(feature = "assert_ne", since = "1.12.0")]
+#[stable(feature = "assert_ne", since = "1.13.0")]
 macro_rules! assert_ne {
     ($left:expr, $right:expr) => ({
         match (&$left, &$right) {
             (left_val, right_val) => {
                 if *left_val == *right_val {
-                    panic!("assertion failed: `(left != right)` \
-                           (left: `{:?}`, right: `{:?}`)", left_val, right_val)
+                    panic!(r#"assertion failed: `(left != right)`
+  left: `{:?}`
+ right: `{:?}`"#, left_val, right_val)
                 }
             }
         }
@@ -166,8 +175,9 @@ macro_rules! assert_ne {
         match (&($left), &($right)) {
             (left_val, right_val) => {
                 if *left_val == *right_val {
-                    panic!("assertion failed: `(left != right)` \
-                           (left: `{:?}`, right: `{:?}`): {}", left_val, right_val,
+                    panic!(r#"assertion failed: `(left != right)`
+  left: `{:?}`
+ right: `{:?}`: {}"#, left_val, right_val,
                            format_args!($($arg)+))
                 }
             }
@@ -183,6 +193,8 @@ macro_rules! assert_ne {
 /// Like [`assert!`], this macro also has a second version, where a custom panic
 /// message can be provided.
 ///
+/// # Uses
+///
 /// Unlike [`assert!`], `debug_assert!` statements are only enabled in non
 /// optimized builds by default. An optimized build will omit all
 /// `debug_assert!` statements unless `-C debug-assertions` is passed to the
@@ -268,7 +280,7 @@ macro_rules! debug_assert_eq {
 /// debug_assert_ne!(a, b);
 /// ```
 #[macro_export]
-#[stable(feature = "assert_ne", since = "1.12.0")]
+#[stable(feature = "assert_ne", since = "1.13.0")]
 macro_rules! debug_assert_ne {
     ($($arg:tt)*) => (if cfg!(debug_assertions) { assert_ne!($($arg)*); })
 }
@@ -379,7 +391,7 @@ macro_rules! try {
 /// assert_eq!(v, b"s = \"abc 123\"");
 /// ```
 #[macro_export]
-#[stable(feature = "core", since = "1.6.0")]
+#[stable(feature = "rust1", since = "1.0.0")]
 macro_rules! write {
     ($dst:expr, $($arg:tt)*) => ($dst.write_fmt(format_args!($($arg)*)))
 }
@@ -479,7 +491,7 @@ macro_rules! writeln {
 /// }
 /// ```
 #[macro_export]
-#[stable(feature = "core", since = "1.6.0")]
+#[stable(feature = "rust1", since = "1.0.0")]
 macro_rules! unreachable {
     () => ({
         panic!("internal error: entered unreachable code")
@@ -540,7 +552,7 @@ macro_rules! unreachable {
 /// }
 /// ```
 #[macro_export]
-#[stable(feature = "core", since = "1.6.0")]
+#[stable(feature = "rust1", since = "1.0.0")]
 macro_rules! unimplemented {
     () => (panic!("not yet implemented"))
 }