Trait std::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...Implementations on Foreign Types
impl Neg for vector_signed_short
[src]
impl Neg for vector_signed_short
[src]type Output = vector_signed_short
pub fn neg(self) -> <vector_signed_short as Neg>::Output
[src]
impl Neg for vector_signed_char
[src]
impl Neg for vector_signed_char
[src]type Output = vector_signed_char
pub fn neg(self) -> <vector_signed_char as Neg>::Output
[src]
impl Neg for vector_signed_int
[src]
impl Neg for vector_signed_int
[src]type Output = vector_signed_int
pub fn neg(self) -> <vector_signed_int as Neg>::Output
[src]
impl Neg for vector_float
[src]
impl Neg for vector_float
[src]type Output = vector_float
pub fn neg(self) -> <vector_float as Neg>::Output
[src]
Implementors
Loading content...