Trait nom::lib::std::ops::Neg1.0.0[][src]

pub trait Neg {
    type Output;
    #[must_use]
    pub fn neg(self) -> Self::Output;
}
[]

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

type Output[src][]

The resulting type after applying the - operator.

Required methods

#[must_use]
pub fn neg(self) -> Self::Output
[src][]

Performs the unary - operation.

Example

let x: i32 = 12;
assert_eq!(-x, -12);

Implementations on Foreign Types

impl Neg for i16[src]

impl<'_> Neg for &'_ isize[src]

impl Neg for Wrapping<u32>[src]

impl Neg for Wrapping<isize>[src]

impl Neg for f32[src]

impl Neg for Wrapping<i8>[src]

impl<'_> Neg for &'_ i8[src]

impl<'_> Neg for &'_ Wrapping<i64>[src]

impl Neg for i32[src]

impl Neg for i128[src]

impl<'_> Neg for &'_ Wrapping<u16>[src]

impl Neg for Wrapping<u8>[src]

impl<'_> Neg for &'_ Wrapping<u128>[src]

impl<'_> Neg for &'_ i16[src]

impl Neg for Wrapping<i64>[src]

impl<'_> Neg for &'_ Wrapping<u32>[src]

impl Neg for Wrapping<usize>[src]

impl<'_> Neg for &'_ Wrapping<i128>[src]

impl<'_> Neg for &'_ f64[src]

impl<'_> Neg for &'_ Wrapping<i16>[src]

impl Neg for Wrapping<u64>[src]

impl<'_> Neg for &'_ i64[src]

impl<'_> Neg for &'_ f32[src]

impl Neg for isize[src]

impl Neg for i8[src]

impl Neg for Wrapping<i32>[src]

impl<'_> Neg for &'_ Wrapping<i8>[src]

impl<'_> Neg for &'_ Wrapping<usize>[src]

impl<'_> Neg for &'_ Wrapping<isize>[src]

impl Neg for f64[src]

impl<'_> Neg for &'_ Wrapping<u64>[src]

impl Neg for i64[src]

impl Neg for Wrapping<u128>[src]

impl Neg for Wrapping<i128>[src]

impl<'_> Neg for &'_ Wrapping<i32>[src]

impl Neg for Wrapping<i16>[src]

impl<'_> Neg for &'_ i128[src]

impl<'_> Neg for &'_ Wrapping<u8>[src]

impl Neg for Wrapping<u16>[src]

impl<'_> Neg for &'_ i32[src]

Implementors

impl<N: Neg<Output = N>> Neg for Deg<N>

impl<N: Neg<Output = N>> Neg for Rad<N>

impl<N, R: Dim, C: Dim, S> Neg for Matrix<N, R, C, S> where
    N: Scalar + ClosedNeg,
    S: Storage<N, R, C>,
    DefaultAllocator: Allocator<N, R, C>, 

impl<'a, N, R: Dim, C: Dim, S> Neg for &'a Matrix<N, R, C, S> where
    N: Scalar + ClosedNeg,
    S: Storage<N, R, C>,
    DefaultAllocator: Allocator<N, R, C>, 

impl<N: Scalar + ClosedNeg, R: Dim, C: Dim> Neg for Unit<MatrixMN<N, R, C>> where
    DefaultAllocator: Allocator<N, R, C>, 

impl<N: Scalar + ClosedNeg, D: DimName> Neg for Point<N, D> where
    DefaultAllocator: Allocator<N, D>, 

impl<'a, N: Scalar + ClosedNeg, D: DimName> Neg for &'a Point<N, D> where
    DefaultAllocator: Allocator<N, D>, 

impl<N: SimdRealField> Neg for Quaternion<N> where
    N::Element: SimdRealField

impl<'a, N: SimdRealField> Neg for &'a Quaternion<N> where
    N::Element: SimdRealField

impl<T: Clone + Num + Neg<Output = T>> Neg for Complex<T>

impl<'a, T: Clone + Num + Neg<Output = T>> Neg for &'a Complex<T>

impl<T> Neg for Ratio<T> where
    T: Clone + Integer + Neg<Output = T>, 

impl<'a, T> Neg for &'a Ratio<T> where
    T: Clone + Integer + Neg<Output = T>, 

impl<C: Clone + Signed> Neg for Matrix<C>

impl<'a, T: Neg + Clone> Neg for Property<'a, T> where
    <T as Neg>::Output: Clone

impl<'a, T: Neg + Clone> Neg for PropertyLastValue<'a, T> where
    <T as Neg>::Output: Clone

impl Neg for AutoSimd<[f32; 2]>

impl Neg for AutoSimd<[f32; 4]>

impl Neg for AutoSimd<[f32; 8]>

impl Neg for AutoSimd<[f32; 16]>

impl Neg for AutoSimd<[f64; 2]>

impl Neg for AutoSimd<[f64; 4]>

impl Neg for AutoSimd<[f64; 8]>

impl Neg for AutoSimd<[i128; 1]>

impl Neg for AutoSimd<[i128; 2]>

impl Neg for AutoSimd<[i128; 4]>

impl Neg for AutoSimd<[i16; 2]>

impl Neg for AutoSimd<[i16; 4]>

impl Neg for AutoSimd<[i16; 8]>

impl Neg for AutoSimd<[i16; 16]>

impl Neg for AutoSimd<[i16; 32]>

impl Neg for AutoSimd<[i32; 2]>

impl Neg for AutoSimd<[i32; 4]>

impl Neg for AutoSimd<[i32; 8]>

impl Neg for AutoSimd<[i32; 16]>

impl Neg for AutoSimd<[i64; 2]>

impl Neg for AutoSimd<[i64; 4]>

impl Neg for AutoSimd<[i64; 8]>

impl Neg for AutoSimd<[i8; 2]>

impl Neg for AutoSimd<[i8; 4]>

impl Neg for AutoSimd<[i8; 8]>

impl Neg for AutoSimd<[i8; 16]>

impl Neg for AutoSimd<[i8; 32]>

impl Neg for AutoSimd<[isize; 2]>

impl Neg for AutoSimd<[isize; 4]>

impl Neg for AutoSimd<[isize; 8]>

impl Neg for Duration

impl Neg for Z0

impl<U: Unsigned + NonZero> Neg for PInt<U>

impl<U: Unsigned + NonZero> Neg for NInt<U>

impl Neg for ATerm

impl<V, A> Neg for TArr<V, A> where
    V: Neg,
    A: Neg