Skip to content

Commit

Permalink
Rollup merge of #133301 - GuillaumeGomez:add-example-wrapping-neg, r=…
Browse files Browse the repository at this point in the history
…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
matthiaskrgr authored Nov 24, 2024
2 parents 4ad97f2 + 67bdc9b commit 3c52c9b
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 3c52c9b

Please sign in to comment.