Skip to content

Commit 3f65afa

Browse files
committed
Auto merge of #33067 - notriddle:wrapping_neg, r=alexcrichton
Implement negation for wrapping numerals. Fixes #33037
2 parents 8655587 + 8a8c432 commit 3f65afa

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/libcore/num/wrapping.rs

+9
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,15 @@ macro_rules! wrapping_impl {
275275
*self = *self & other;
276276
}
277277
}
278+
279+
#[stable(feature = "wrapping_neg", since = "1.10.0")]
280+
impl Neg for Wrapping<$t> {
281+
type Output = Self;
282+
#[inline(always)]
283+
fn neg(self) -> Self {
284+
Wrapping(0) - self
285+
}
286+
}
278287
)*)
279288
}
280289

0 commit comments

Comments
 (0)