Skip to content

Commit f413935

Browse files
authored
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`
2 parents 6112cfd + 30aa6db commit f413935

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

core/src/num/int_macros.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2101,6 +2101,7 @@ macro_rules! int_impl {
21012101
///
21022102
/// ```
21032103
#[doc = concat!("assert_eq!(100", stringify!($SelfT), ".wrapping_neg(), -100);")]
2104+
#[doc = concat!("assert_eq!((-100", stringify!($SelfT), ").wrapping_neg(), 100);")]
21042105
#[doc = concat!("assert_eq!(", stringify!($SelfT), "::MIN.wrapping_neg(), ", stringify!($SelfT), "::MIN);")]
21052106
/// ```
21062107
#[stable(feature = "num_wrapping", since = "1.2.0")]

0 commit comments

Comments
 (0)