Trait core::ops::Neg 1.0.0[−][src]
The unary negation operator -.
Examples
An implementation of Neg for Sign, which allows the use of - to
negate its value.
use std::ops::Neg; #[derive(Debug, PartialEq)] enum Sign { Negative, Zero, Positive, } impl Neg for Sign { type Output = Self; fn neg(self) -> Self::Output { match self { Sign::Negative => Sign::Positive, Sign::Zero => Sign::Zero, Sign::Positive => Sign::Negative, } } } // A negative positive is a negative. assert_eq!(-Sign::Positive, Sign::Negative); // A double negative is a positive. assert_eq!(-Sign::Negative, Sign::Positive); // Zero is its own negation. assert_eq!(-Sign::Zero, Sign::Zero);Run
Associated Types
Loading content...Required methods
Loading content...Implementors
impl Neg for &Wrapping<i8>1.14.0[src]
impl Neg for &Wrapping<i16>1.14.0[src]
impl Neg for &Wrapping<i32>1.14.0[src]
impl Neg for &Wrapping<i64>1.14.0[src]
impl Neg for &Wrapping<i128>1.14.0[src]
impl Neg for &Wrapping<isize>1.14.0[src]
impl Neg for &Wrapping<u8>1.14.0[src]
impl Neg for &Wrapping<u16>1.14.0[src]
impl Neg for &Wrapping<u32>1.14.0[src]
impl Neg for &Wrapping<u64>1.14.0[src]
impl Neg for &Wrapping<u128>1.14.0[src]
impl Neg for &Wrapping<usize>1.14.0[src]
impl Neg for &f32[src]
impl Neg for &f64[src]
impl Neg for &i8[src]
impl Neg for &i16[src]
impl Neg for &i32[src]
impl Neg for &i64[src]
impl Neg for &i128[src]
impl Neg for &isize[src]
impl Neg for vector_float[src]
This is supported on PowerPC or PowerPC-64 only.
type Output = vector_float
fn neg(self) -> Self::Output[src]
impl Neg for vector_signed_char[src]
This is supported on PowerPC or PowerPC-64 only.
type Output = vector_signed_char
fn neg(self) -> Self::Output[src]
impl Neg for vector_signed_int[src]
This is supported on PowerPC or PowerPC-64 only.
type Output = vector_signed_int
fn neg(self) -> Self::Output[src]
impl Neg for vector_signed_short[src]
This is supported on PowerPC or PowerPC-64 only.