Trait tract_hir::internal::tract_downcast_rs::__std::ops::Neg1.0.0[][src]

#[lang = "neg"]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.

Loading content...

Required methods

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

Performs the unary - operation.

Example

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

Implementations on Foreign Types

impl Neg for i64[src]

type Output = i64

impl Neg for f64[src]

type Output = f64

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

type Output = <f64 as Neg>::Output

impl Neg for i8[src]

type Output = i8

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

type Output = <i8 as Neg>::Output

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

type Output = <isize as Neg>::Output

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

type Output = <i128 as Neg>::Output

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

type Output = <i16 as Neg>::Output

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

type Output = <i64 as Neg>::Output

impl Neg for i16[src]

type Output = i16

impl Neg for isize[src]

type Output = isize

impl Neg for i32[src]

type Output = i32

impl Neg for i128[src]

type Output = i128

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

type Output = <f32 as Neg>::Output

impl Neg for f32[src]

type Output = f32

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

type Output = <i32 as Neg>::Output

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

type Output = Complex<T>

impl<T> Neg for Complex<T> where
    T: Clone + Num + Neg<Output = T>, 
[src]

type Output = Complex<T>

Loading content...

Implementors

impl Neg for TDim

type Output = TDim

impl Neg for f16

type Output = f16

impl Neg for Wrapping<i8>1.10.0[src]

type Output = Wrapping<i8>

impl Neg for Wrapping<i16>1.10.0[src]

type Output = Wrapping<i16>

impl Neg for Wrapping<i32>1.10.0[src]

type Output = Wrapping<i32>

impl Neg for Wrapping<i64>1.10.0[src]

type Output = Wrapping<i64>

impl Neg for Wrapping<i128>1.10.0[src]

type Output = Wrapping<i128>

impl Neg for Wrapping<isize>1.10.0[src]

type Output = Wrapping<isize>

impl Neg for Wrapping<u8>1.10.0[src]

type Output = Wrapping<u8>

impl Neg for Wrapping<u16>1.10.0[src]

type Output = Wrapping<u16>

impl Neg for Wrapping<u32>1.10.0[src]

type Output = Wrapping<u32>

impl Neg for Wrapping<u64>1.10.0[src]

type Output = Wrapping<u64>

impl Neg for Wrapping<u128>1.10.0[src]

type Output = Wrapping<u128>

impl Neg for Wrapping<usize>1.10.0[src]

type Output = Wrapping<usize>

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

type Output = <Wrapping<i8> as Neg>::Output

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

type Output = <Wrapping<i16> as Neg>::Output

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

type Output = <Wrapping<i32> as Neg>::Output

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

type Output = <Wrapping<i64> as Neg>::Output

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

type Output = <Wrapping<i128> as Neg>::Output

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

type Output = <Wrapping<isize> as Neg>::Output

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

type Output = <Wrapping<u8> as Neg>::Output

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

type Output = <Wrapping<u16> as Neg>::Output

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

type Output = <Wrapping<u32> as Neg>::Output

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

type Output = <Wrapping<u64> as Neg>::Output

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

type Output = <Wrapping<u128> as Neg>::Output

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

type Output = <Wrapping<usize> as Neg>::Output

impl<'a, A, S, D> Neg for &'a ArrayBase<S, D> where
    S: Data<Elem = A>,
    D: Dimension,
    &'a A: 'a,
    &'a A: Neg,
    <&'a A as Neg>::Output == A, 
[src]

type Output = ArrayBase<OwnedRepr<A>, D>

pub fn neg(self) -> ArrayBase<OwnedRepr<A>, D>[src]

Perform an elementwise negation of reference self and return the result as a new Array.

impl<A, S, D> Neg for ArrayBase<S, D> where
    S: DataOwned<Elem = A> + DataMut,
    A: Clone + Neg<Output = A>,
    D: Dimension
[src]

type Output = ArrayBase<S, D>

pub fn neg(self) -> ArrayBase<S, D>[src]

Perform an elementwise negation of self and return the result.

impl<T> Neg for GenericFactoid<T> where
    T: Neg<Output = T> + PartialEq + Clone + Debug + Hash
[src]

Loading content...