Trait nom::lib::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);
Associated Types
Loading content...Required methods
Loading content...Implementations on Foreign Types
impl<'_> Neg for &'_ isize
[src]
impl<'_> Neg for &'_ isize
[src]impl Neg for Wrapping<isize>
[src]
impl Neg for Wrapping<isize>
[src]impl<'_> Neg for &'_ i8
[src]
impl<'_> Neg for &'_ i8
[src]impl<'_> Neg for &'_ Wrapping<i64>
[src]
impl<'_> Neg for &'_ Wrapping<i64>
[src]impl<'_> Neg for &'_ Wrapping<u16>
[src]
impl<'_> Neg for &'_ Wrapping<u16>
[src]impl<'_> Neg for &'_ Wrapping<u128>
[src]
impl<'_> Neg for &'_ Wrapping<u128>
[src]impl<'_> Neg for &'_ i16
[src]
impl<'_> Neg for &'_ i16
[src]impl<'_> Neg for &'_ Wrapping<u32>
[src]
impl<'_> Neg for &'_ Wrapping<u32>
[src]impl Neg for Wrapping<usize>
[src]
impl Neg for Wrapping<usize>
[src]impl<'_> Neg for &'_ Wrapping<i128>
[src]
impl<'_> Neg for &'_ Wrapping<i128>
[src]impl<'_> Neg for &'_ f64
[src]
impl<'_> Neg for &'_ f64
[src]impl<'_> Neg for &'_ Wrapping<i16>
[src]
impl<'_> Neg for &'_ Wrapping<i16>
[src]impl<'_> Neg for &'_ i64
[src]
impl<'_> Neg for &'_ i64
[src]impl<'_> Neg for &'_ f32
[src]
impl<'_> Neg for &'_ f32
[src]impl<'_> Neg for &'_ Wrapping<i8>
[src]
impl<'_> Neg for &'_ Wrapping<i8>
[src]impl<'_> Neg for &'_ Wrapping<usize>
[src]
impl<'_> Neg for &'_ Wrapping<usize>
[src]impl<'_> Neg for &'_ Wrapping<isize>
[src]
impl<'_> Neg for &'_ Wrapping<isize>
[src]impl<'_> Neg for &'_ Wrapping<u64>
[src]
impl<'_> Neg for &'_ Wrapping<u64>
[src]impl<'_> Neg for &'_ Wrapping<i32>
[src]
impl<'_> Neg for &'_ Wrapping<i32>
[src]impl<'_> Neg for &'_ i128
[src]
impl<'_> Neg for &'_ i128
[src]impl<'_> Neg for &'_ Wrapping<u8>
[src]
impl<'_> Neg for &'_ Wrapping<u8>
[src]impl<'_> Neg for &'_ i32
[src]
impl<'_> Neg for &'_ i32
[src]