about summary refs log tree commit diff
diff options
context:
space:
mode:
authorScott McMurray <scottmcm@users.noreply.github.com>2023-04-07 20:09:15 -0700
committerScott McMurray <scottmcm@users.noreply.github.com>2023-04-07 20:09:15 -0700
commited0b8af50527de7b368a87828ec9de0fb0292158 (patch)
tree3319e129f7fedd22facd88adbfdadf137d32930a
parent0534655d9b5f61dbd75cf142ec8d2d3f68b550ee (diff)
downloadrust-ed0b8af50527de7b368a87828ec9de0fb0292158.tar.gz
rust-ed0b8af50527de7b368a87828ec9de0fb0292158.zip
The `wrapping_neg` example for unsigned types shouldn't use `i8`
-rw-r--r--library/core/src/num/uint_macros.rs9
1 files changed, 4 insertions, 5 deletions
diff --git a/library/core/src/num/uint_macros.rs b/library/core/src/num/uint_macros.rs
index 932038a0b01..114deeea387 100644
--- a/library/core/src/num/uint_macros.rs
+++ b/library/core/src/num/uint_macros.rs
@@ -1363,12 +1363,11 @@ macro_rules! uint_impl {
         ///
         /// Basic usage:
         ///
-        /// Please note that this example is shared between integer types.
-        /// Which explains why `i8` is used here.
-        ///
         /// ```
-        /// assert_eq!(100i8.wrapping_neg(), -100);
-        /// assert_eq!((-128i8).wrapping_neg(), -128);
+        #[doc = concat!("assert_eq!(0_", stringify!($SelfT), ".wrapping_neg(), 0);")]
+        #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MAX.wrapping_neg(), 1);")]
+        #[doc = concat!("assert_eq!(13_", stringify!($SelfT), ".wrapping_neg(), (!13) + 1);")]
+        #[doc = concat!("assert_eq!(42_", stringify!($SelfT), ".wrapping_neg(), !(42 - 1));")]
         /// ```
         #[stable(feature = "num_wrapping", since = "1.2.0")]
         #[rustc_const_stable(feature = "const_wrapping_math", since = "1.32.0")]