Trait Neg

1.6.0 ยท Source
pub trait Neg {
    type Output;

    // Required method
    fn neg(self) -> Self::Output;
}
Expand description

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);

Required Associated Typesยง

1.0.0 ยท Source

type Output

The resulting type after applying the - operator.

Required Methodsยง

1.0.0 ยท Source

fn neg(self) -> Self::Output

Performs the unary - operation.

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

Implementorsยง

1.0.0 ยท Sourceยง

impl Neg for &f16

1.0.0 ยท Sourceยง

impl Neg for &f32

1.0.0 ยท Sourceยง

impl Neg for &f64

1.0.0 ยท Sourceยง

impl Neg for &f128

1.0.0 ยท Sourceยง

impl Neg for &i8

1.0.0 ยท Sourceยง

impl Neg for &i16

1.0.0 ยท Sourceยง

impl Neg for &i32

1.0.0 ยท Sourceยง

impl Neg for &i64

1.0.0 ยท Sourceยง

impl Neg for &i128

1.0.0 ยท Sourceยง

impl Neg for &isize

1.71.0 ยท Sourceยง

impl Neg for &NonZero<i8>

1.71.0 ยท Sourceยง

impl Neg for &NonZero<i16>

1.71.0 ยท Sourceยง

impl Neg for &NonZero<i32>

1.71.0 ยท Sourceยง

impl Neg for &NonZero<i64>

1.71.0 ยท Sourceยง

impl Neg for &NonZero<i128>

1.71.0 ยท Sourceยง

impl Neg for &NonZero<isize>

1.74.0 ยท Sourceยง

impl Neg for &Saturating<i8>

1.74.0 ยท Sourceยง

impl Neg for &Saturating<i16>

1.74.0 ยท Sourceยง

impl Neg for &Saturating<i32>

1.74.0 ยท Sourceยง

impl Neg for &Saturating<i64>

1.74.0 ยท Sourceยง

impl Neg for &Saturating<i128>

1.74.0 ยท Sourceยง

impl Neg for &Saturating<isize>

1.14.0 ยท Sourceยง

impl Neg for &Wrapping<i8>

1.14.0 ยท Sourceยง

impl Neg for &Wrapping<i16>

1.14.0 ยท Sourceยง

impl Neg for &Wrapping<i32>

1.14.0 ยท Sourceยง

impl Neg for &Wrapping<i64>

1.14.0 ยท Sourceยง

impl Neg for &Wrapping<i128>

1.14.0 ยท Sourceยง

impl Neg for &Wrapping<isize>

1.14.0 ยท Sourceยง

impl Neg for &Wrapping<u8>

1.14.0 ยท Sourceยง

impl Neg for &Wrapping<u16>

1.14.0 ยท Sourceยง

impl Neg for &Wrapping<u32>

1.14.0 ยท Sourceยง

impl Neg for &Wrapping<u64>

1.14.0 ยท Sourceยง

impl Neg for &Wrapping<u128>

1.14.0 ยท Sourceยง

impl Neg for &Wrapping<usize>

Sourceยง

impl Neg for &BigInt

Sourceยง

impl Neg for &Number

Sourceยง

impl Neg for &BigNum

Sourceยง

impl Neg for &BigNumRef

Sourceยง

impl Neg for &JsValue

ยง

impl Neg for &Rgb

ยง

type Output = Rgb

1.0.0 ยท Sourceยง

impl Neg for f16

1.0.0 ยท Sourceยง

impl Neg for f32

1.0.0 ยท Sourceยง

impl Neg for f64

1.0.0 ยท Sourceยง

impl Neg for f128

1.0.0 ยท Sourceยง

impl Neg for i8

1.0.0 ยท Sourceยง

impl Neg for i16

1.0.0 ยท Sourceยง

impl Neg for i32

1.0.0 ยท Sourceยง

impl Neg for i64

1.0.0 ยท Sourceยง

impl Neg for i128

1.0.0 ยท Sourceยง

impl Neg for isize

1.71.0 ยท Sourceยง

impl Neg for NonZero<i8>

1.71.0 ยท Sourceยง

impl Neg for NonZero<i16>

1.71.0 ยท Sourceยง

impl Neg for NonZero<i32>

1.71.0 ยท Sourceยง

impl Neg for NonZero<i64>

1.71.0 ยท Sourceยง

impl Neg for NonZero<i128>

1.71.0 ยท Sourceยง

impl Neg for NonZero<isize>

1.74.0 ยท Sourceยง

impl Neg for Saturating<i8>

1.74.0 ยท Sourceยง

impl Neg for Saturating<i16>

1.74.0 ยท Sourceยง

impl Neg for Saturating<i32>

1.74.0 ยท Sourceยง

impl Neg for Saturating<i64>

1.74.0 ยท Sourceยง

impl Neg for Saturating<i128>

1.74.0 ยท Sourceยง

impl Neg for Saturating<isize>

1.10.0 ยท Sourceยง

impl Neg for Wrapping<i8>

1.10.0 ยท Sourceยง

impl Neg for Wrapping<i16>

1.10.0 ยท Sourceยง

impl Neg for Wrapping<i32>

1.10.0 ยท Sourceยง

impl Neg for Wrapping<i64>

1.10.0 ยท Sourceยง

impl Neg for Wrapping<i128>

1.10.0 ยท Sourceยง

impl Neg for Wrapping<isize>

1.10.0 ยท Sourceยง

impl Neg for Wrapping<u8>

1.10.0 ยท Sourceยง

impl Neg for Wrapping<u16>

1.10.0 ยท Sourceยง

impl Neg for Wrapping<u32>

1.10.0 ยท Sourceยง

impl Neg for Wrapping<u64>

1.10.0 ยท Sourceยง

impl Neg for Wrapping<u128>

1.10.0 ยท Sourceยง

impl Neg for Wrapping<usize>

Sourceยง

impl Neg for TimeDelta

Sourceยง

impl Neg for BigInt

Sourceยง

type Output = <&'static BigInt as Neg>::Output

Sourceยง

impl Neg for Number

Sourceยง

type Output = <&'static Number as Neg>::Output

Sourceยง

impl Neg for BigNum

Sourceยง

impl Neg for ATerm

Sourceยง

impl Neg for Z0

-Z0 = Z0

Sourceยง

impl Neg for JsValue

Sourceยง

type Output = <&'static JsValue as Neg>::Output

ยง

impl Neg for Double

ยง

type Output = Double

ยง

impl Neg for Duration

ยง

type Output = Duration

ยง

impl Neg for Expression

ยง

type Output = Expression

ยง

impl Neg for Float

ยง

type Output = Float

ยง

impl Neg for Rgb

ยง

type Output = Rgb

ยง

impl Neg for Timespec

ยง

type Output = Timespec

ยง

impl Neg for UtcOffset

ยง

type Output = UtcOffset

ยง

impl<O> Neg for F32<O>
where O: ByteOrder,

ยง

type Output = F32<O>

ยง

impl<O> Neg for F64<O>
where O: ByteOrder,

ยง

type Output = F64<O>

ยง

impl<O> Neg for I16<O>
where O: ByteOrder,

ยง

type Output = I16<O>

ยง

impl<O> Neg for I32<O>
where O: ByteOrder,

ยง

type Output = I32<O>

ยง

impl<O> Neg for I64<O>
where O: ByteOrder,

ยง

type Output = I64<O>

ยง

impl<O> Neg for I128<O>
where O: ByteOrder,

ยง

type Output = I128<O>

ยง

impl<O> Neg for Isize<O>
where O: ByteOrder,

ยง

type Output = Isize<O>

Sourceยง

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

-NInt = PInt

Sourceยง

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

-PInt = NInt

Sourceยง

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

Sourceยง

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

Sourceยง

impl<const N: usize> Neg for Simd<f32, N>

Sourceยง

impl<const N: usize> Neg for Simd<f64, N>

Sourceยง

impl<const N: usize> Neg for Simd<i8, N>

Sourceยง

impl<const N: usize> Neg for Simd<i16, N>

Sourceยง

impl<const N: usize> Neg for Simd<i32, N>

Sourceยง

impl<const N: usize> Neg for Simd<i64, N>

Sourceยง

impl<const N: usize> Neg for Simd<isize, N>