1.0.0[][src]Trait af_lib::prelude::af_core::test::prelude::Neg

#[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 &'_ Wrapping<u16>[src]

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

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

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

impl Neg for Wrapping<u16>[src]

type Output = Wrapping<u16>

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

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

impl Neg for Wrapping<isize>[src]

type Output = Wrapping<isize>

impl Neg for f32[src]

type Output = f32

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

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

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

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

impl Neg for i32[src]

type Output = i32

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

type Output = <i8 as Neg>::Output

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

type Output = <f64 as Neg>::Output

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

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

impl Neg for Wrapping<i8>[src]

type Output = Wrapping<i8>

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

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

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

type Output = <isize as Neg>::Output

impl Neg for Wrapping<i64>[src]

type Output = Wrapping<i64>

impl Neg for Wrapping<i128>[src]

type Output = Wrapping<i128>

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

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

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

type Output = <f32 as Neg>::Output

impl Neg for f64[src]

type Output = f64

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

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

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

type Output = <i32 as Neg>::Output

impl Neg for i128[src]

type Output = i128

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

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

impl Neg for i16[src]

type Output = i16

impl Neg for Wrapping<usize>[src]

type Output = Wrapping<usize>

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

type Output = <i16 as Neg>::Output

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

type Output = <i128 as Neg>::Output

impl Neg for isize[src]

type Output = isize

impl Neg for Wrapping<i16>[src]

type Output = Wrapping<i16>

impl Neg for Wrapping<u128>[src]

type Output = Wrapping<u128>

impl Neg for Wrapping<u32>[src]

type Output = Wrapping<u32>

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

type Output = <i64 as Neg>::Output

impl Neg for i8[src]

type Output = i8

impl Neg for Wrapping<u8>[src]

type Output = Wrapping<u8>

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

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

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

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

impl Neg for Wrapping<i32>[src]

type Output = Wrapping<i32>

impl Neg for Wrapping<u64>[src]

type Output = Wrapping<u64>

impl Neg for Duration[src]

type Output = Duration

impl<'a> Neg for &'a BigUint[src]

type Output = BigUint

impl Neg for Sign[src]

type Output = Sign

pub fn neg(self) -> Sign[src]

Negate Sign value.

impl Neg for BigInt[src]

type Output = BigInt

impl<'a> Neg for &'a BigInt[src]

type Output = BigInt

impl Neg for BigUint[src]

type Output = BigUint

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

type Output = Complex<T>

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

type Output = Complex<T>

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

type Output = Ratio<T>

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

type Output = Ratio<T>

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

-PInt = NInt

type Output = NInt<U>

impl Neg for Z0

-Z0 = Z0

type Output = Z0

impl Neg for ATerm

type Output = ATerm

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

type Output = TArr<<V as Neg>::Output, <A as Neg>::Output>

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

-NInt = PInt

type Output = PInt<U>

impl<'a> Neg for &'a BigNumRef[src]

type Output = BigNum

impl Neg for BigNum[src]

type Output = BigNum

impl<'a> Neg for &'a BigNum[src]

type Output = BigNum

Loading content...

Implementors

Loading content...