mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-07 13:25:45 +00:00
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:
commit
3c52c9b483
@ -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")]
|
||||
|
Loading…
Reference in New Issue
Block a user