Function neg

Source
pub fn neg(op: i32) -> i32
Expand description

Computes the negation of the operand, saturating on overflow. This serves as the definition of the negation operation throughout the library.

§Parameters

  • op: The operand.

§Returns

The negation of the operand.

§Examples

assert_eq!(neg(1), -1);
assert_eq!(neg(i32::MAX), i32::MIN + 1);
assert_eq!(neg(i32::MIN), i32::MAX);