Neg

Trait Neg 

1.0.0 (const: unstable) · 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 (const: unstable) · Source§

impl Neg for &f16

1.0.0 (const: unstable) · Source§

impl Neg for &f32

1.0.0 (const: unstable) · Source§

impl Neg for &f64

1.0.0 (const: unstable) · Source§

impl Neg for &f128

1.0.0 (const: unstable) · Source§

impl Neg for &i8

1.0.0 (const: unstable) · Source§

impl Neg for &i16

1.0.0 (const: unstable) · Source§

impl Neg for &i32

1.0.0 (const: unstable) · Source§

impl Neg for &i64

1.0.0 (const: unstable) · Source§

impl Neg for &i128

1.0.0 (const: unstable) · Source§

impl Neg for &isize

1.71.0 (const: unstable) · Source§

impl Neg for &NonZero<i8>

1.71.0 (const: unstable) · Source§

impl Neg for &NonZero<i16>

1.71.0 (const: unstable) · Source§

impl Neg for &NonZero<i32>

1.71.0 (const: unstable) · Source§

impl Neg for &NonZero<i64>

1.71.0 (const: unstable) · Source§

impl Neg for &NonZero<i128>

1.71.0 (const: unstable) · Source§

impl Neg for &NonZero<isize>

1.74.0 (const: unstable) · Source§

impl Neg for &Saturating<i8>

1.74.0 (const: unstable) · Source§

impl Neg for &Saturating<i16>

1.74.0 (const: unstable) · Source§

impl Neg for &Saturating<i32>

1.74.0 (const: unstable) · Source§

impl Neg for &Saturating<i64>

1.74.0 (const: unstable) · Source§

impl Neg for &Saturating<i128>

1.74.0 (const: unstable) · Source§

impl Neg for &Saturating<isize>

1.14.0 (const: unstable) · Source§

impl Neg for &datex_core::without_std::num::Wrapping<i8>

1.14.0 (const: unstable) · Source§

impl Neg for &datex_core::without_std::num::Wrapping<i16>

1.14.0 (const: unstable) · Source§

impl Neg for &datex_core::without_std::num::Wrapping<i32>

1.14.0 (const: unstable) · Source§

impl Neg for &datex_core::without_std::num::Wrapping<i64>

1.14.0 (const: unstable) · Source§

impl Neg for &datex_core::without_std::num::Wrapping<i128>

1.14.0 (const: unstable) · Source§

impl Neg for &datex_core::without_std::num::Wrapping<isize>

1.14.0 (const: unstable) · Source§

impl Neg for &datex_core::without_std::num::Wrapping<u8>

1.14.0 (const: unstable) · Source§

impl Neg for &datex_core::without_std::num::Wrapping<u16>

1.14.0 (const: unstable) · Source§

impl Neg for &datex_core::without_std::num::Wrapping<u32>

1.14.0 (const: unstable) · Source§

impl Neg for &datex_core::without_std::num::Wrapping<u64>

1.14.0 (const: unstable) · Source§

impl Neg for &datex_core::without_std::num::Wrapping<u128>

1.14.0 (const: unstable) · Source§

impl Neg for &datex_core::without_std::num::Wrapping<usize>

Source§

impl Neg for &BigDecimal

Source§

impl Neg for &Rgb

Source§

impl Neg for &BigInt

Source§

impl Neg for &BigNum

Source§

impl Neg for &BigNumRef

Source§

impl Neg for CoreValue

Source§

impl Neg for Decimal

Source§

impl Neg for TypedDecimal

Source§

impl Neg for TypedInteger

Source§

impl Neg for ValueContainer

Source§

impl Neg for Sign

1.0.0 (const: unstable) · Source§

impl Neg for f16

1.0.0 (const: unstable) · Source§

impl Neg for f32

1.0.0 (const: unstable) · Source§

impl Neg for f64

1.0.0 (const: unstable) · Source§

impl Neg for f128

1.0.0 (const: unstable) · Source§

impl Neg for i8

1.0.0 (const: unstable) · Source§

impl Neg for i16

1.0.0 (const: unstable) · Source§

impl Neg for i32

1.0.0 (const: unstable) · Source§

impl Neg for i64

1.0.0 (const: unstable) · Source§

impl Neg for i128

1.0.0 (const: unstable) · Source§

impl Neg for isize

Source§

impl Neg for Rational

Source§

impl Neg for Integer

Source§

impl Neg for Value

1.71.0 (const: unstable) · Source§

impl Neg for NonZero<i8>

1.71.0 (const: unstable) · Source§

impl Neg for NonZero<i16>

1.71.0 (const: unstable) · Source§

impl Neg for NonZero<i32>

1.71.0 (const: unstable) · Source§

impl Neg for NonZero<i64>

1.71.0 (const: unstable) · Source§

impl Neg for NonZero<i128>

1.71.0 (const: unstable) · Source§

impl Neg for NonZero<isize>

1.74.0 (const: unstable) · Source§

impl Neg for Saturating<i8>

1.74.0 (const: unstable) · Source§

impl Neg for Saturating<i16>

1.74.0 (const: unstable) · Source§

impl Neg for Saturating<i32>

1.74.0 (const: unstable) · Source§

impl Neg for Saturating<i64>

1.74.0 (const: unstable) · Source§

impl Neg for Saturating<i128>

1.74.0 (const: unstable) · Source§

impl Neg for Saturating<isize>

1.10.0 (const: unstable) · Source§

impl Neg for datex_core::without_std::num::Wrapping<i8>

1.10.0 (const: unstable) · Source§

impl Neg for datex_core::without_std::num::Wrapping<i16>

1.10.0 (const: unstable) · Source§

impl Neg for datex_core::without_std::num::Wrapping<i32>

1.10.0 (const: unstable) · Source§

impl Neg for datex_core::without_std::num::Wrapping<i64>

1.10.0 (const: unstable) · Source§

impl Neg for datex_core::without_std::num::Wrapping<i128>

1.10.0 (const: unstable) · Source§

impl Neg for datex_core::without_std::num::Wrapping<isize>

1.10.0 (const: unstable) · Source§

impl Neg for datex_core::without_std::num::Wrapping<u8>

1.10.0 (const: unstable) · Source§

impl Neg for datex_core::without_std::num::Wrapping<u16>

1.10.0 (const: unstable) · Source§

impl Neg for datex_core::without_std::num::Wrapping<u32>

1.10.0 (const: unstable) · Source§

impl Neg for datex_core::without_std::num::Wrapping<u64>

1.10.0 (const: unstable) · Source§

impl Neg for datex_core::without_std::num::Wrapping<u128>

1.10.0 (const: unstable) · Source§

impl Neg for datex_core::without_std::num::Wrapping<usize>

Source§

impl Neg for BigDecimal

Source§

impl Neg for BigDecimalRef<'_>

Source§

impl Neg for TimeDelta

Source§

impl Neg for crypto_bigint::wrapping::Wrapping<Limb>

Source§

impl Neg for EdwardsPoint

Source§

impl Neg for RistrettoPoint

Source§

impl Neg for curve25519_dalek::scalar::Scalar

Source§

impl Neg for TimeSpec

Source§

impl Neg for TimeVal

Source§

impl Neg for Rgb

Source§

impl Neg for BigInt

Source§

impl Neg for BigNum

Source§

impl Neg for p256::arithmetic::scalar::Scalar

Source§

impl Neg for p384::arithmetic::scalar::Scalar

Source§

impl Neg for Duration

Source§

impl Neg for UtcOffset

Source§

impl Neg for ATerm

Source§

impl Neg for Z0

-Z0 = Z0

Source§

impl<'a> Neg for &'a EdwardsPoint

Source§

impl<'a> Neg for &'a RistrettoPoint

Source§

impl<'a> Neg for &'a curve25519_dalek::scalar::Scalar

Source§

impl<'a> Neg for &'a p256::arithmetic::scalar::Scalar

Source§

impl<'a, C> Neg for &'a ProjectivePoint<C>

Source§

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

Source§

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

Source§

impl<'a, T> Neg for &'a OrderedFloat<T>
where &'a T: Neg,

Source§

impl<C> Neg for &ScalarPrimitive<C>
where C: Curve,

Source§

impl<C> Neg for &AffinePoint<C>

Source§

impl<C> Neg for NonZeroScalar<C>
where C: CurveArithmetic,

Source§

impl<C> Neg for ScalarPrimitive<C>
where C: Curve,

Source§

impl<C> Neg for AffinePoint<C>

Source§

impl<C> Neg for ProjectivePoint<C>

Source§

impl<MOD, const LIMBS: usize> Neg for &Residue<MOD, LIMBS>
where MOD: ResidueParams<LIMBS>,

Source§

type Output = Residue<MOD, LIMBS>

Source§

impl<MOD, const LIMBS: usize> Neg for Residue<MOD, LIMBS>
where MOD: ResidueParams<LIMBS>,

Source§

type Output = Residue<MOD, LIMBS>

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

impl<T> Neg for &NotNan<T>
where T: FloatCore,

Source§

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

Source§

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

Source§

impl<T> Neg for NotNan<T>
where T: FloatCore,

Source§

impl<T> Neg for OrderedFloat<T>
where T: Neg,

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 LIMBS: usize> Neg for &DynResidue<LIMBS>

Source§

impl<const LIMBS: usize> Neg for DynResidue<LIMBS>

Source§

impl<const LIMBS: usize> Neg for crypto_bigint::wrapping::Wrapping<Uint<LIMBS>>

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>