Skip to content

Commit

Permalink
Rollup merge of rust-lang#133301 - GuillaumeGomez:add-example-wrappin…
Browse files Browse the repository at this point in the history
…g-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`
  • Loading branch information
jieyouxu authored Nov 22, 2024
2 parents 2228a9c + f74fdd2 commit 3248214
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions library/core/src/num/int_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down

0 comments on commit 3248214

Please sign in to comment.