Rollup merge of #133301 - GuillaumeGomez:add-example-wrapping-neg, r=workingjubilee

Add code example for `wrapping_neg` method for signed integers

With this example, we make it obvious that `wrapping_neg` works both ways (neg to pos and pos to neg).

r? `@workingjubilee`
This commit is contained in:
Matthias Krüger 2024-11-24 11:08:19 +01:00 committed by GitHub
commit 3c52c9b483
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2101,6 +2101,7 @@ macro_rules! int_impl {
///
/// ```
#[doc = concat!("assert_eq!(100", stringify!($SelfT), ".wrapping_neg(), -100);")]
#[doc = concat!("assert_eq!((-100", stringify!($SelfT), ").wrapping_neg(), 100);")]
#[doc = concat!("assert_eq!(", stringify!($SelfT), "::MIN.wrapping_neg(), ", stringify!($SelfT), "::MIN);")]
/// ```
#[stable(feature = "num_wrapping", since = "1.2.0")]