Skip to content

Commit 75a4625

Browse files
authored
Rollup merge of #110070 - scottmcm:wrapping-neg, r=cuviper
The `wrapping_neg` example for unsigned types shouldn't use `i8` Probably it should have at least one example with an unsigned type.
2 parents 788de47 + ed0b8af commit 75a4625

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

library/core/src/num/uint_macros.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -1363,12 +1363,11 @@ macro_rules! uint_impl {
13631363
///
13641364
/// Basic usage:
13651365
///
1366-
/// Please note that this example is shared between integer types.
1367-
/// Which explains why `i8` is used here.
1368-
///
13691366
/// ```
1370-
/// assert_eq!(100i8.wrapping_neg(), -100);
1371-
/// assert_eq!((-128i8).wrapping_neg(), -128);
1367+
#[doc = concat!("assert_eq!(0_", stringify!($SelfT), ".wrapping_neg(), 0);")]
1368+
#[doc = concat!("assert_eq!(", stringify!($SelfT), "::MAX.wrapping_neg(), 1);")]
1369+
#[doc = concat!("assert_eq!(13_", stringify!($SelfT), ".wrapping_neg(), (!13) + 1);")]
1370+
#[doc = concat!("assert_eq!(42_", stringify!($SelfT), ".wrapping_neg(), !(42 - 1));")]
13721371
/// ```
13731372
#[stable(feature = "num_wrapping", since = "1.2.0")]
13741373
#[rustc_const_stable(feature = "const_wrapping_math", since = "1.32.0")]

0 commit comments

Comments
 (0)