Skip to content

Commit

Permalink
Unrolled build for rust-lang#133301
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#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`
  • Loading branch information
rust-timer authored Nov 24, 2024
2 parents ab3cf26 + 67bdc9b commit 2e8e055
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 2e8e055

Please sign in to comment.