Trait sp_std::ops::Neg

1.0.0 · source ·
pub trait Neg {
    type Output;

    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§

The resulting type after applying the - operator.

Required Methods§

Performs the unary - operation.

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

Implementors§

impl<'a> Neg for &'a Scalar

impl<'a> Neg for Scalar

impl<'a> Neg for &'a EdwardsPoint

impl Neg for EdwardsPoint

impl<'a> Neg for &'a RistrettoPoint

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

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

impl<C> Neg for NonZeroScalar<C>where
    C: Curve + ScalarArithmetic,

impl<Frac> Neg for FixedI8<Frac>

impl<Frac> Neg for &FixedI8<Frac>

impl<Frac> Neg for FixedI16<Frac>

impl<Frac> Neg for &FixedI16<Frac>

impl<Frac> Neg for FixedI32<Frac>

impl<Frac> Neg for &FixedI32<Frac>

impl<Frac> Neg for FixedI64<Frac>

impl<Frac> Neg for &FixedI64<Frac>

impl<Frac> Neg for FixedI128<Frac>

impl<Frac> Neg for &FixedI128<Frac>

impl<F: Fixed> Neg for Unwrapped<F>

impl<F: Fixed> Neg for &Unwrapped<F>

impl<F: Fixed> Neg for Wrapping<F>

impl<F: Fixed> Neg for &Wrapping<F>

impl Neg for bf16

impl Neg for f16

impl Neg for &BigInt

impl Neg for BigInt

impl Neg for &Number

impl Neg for Number

impl Neg for AffinePoint

impl<'a> Neg for &'a ProjectivePoint

impl Neg for Scalar

impl Neg for &Scalar

impl Neg for Scalar

impl<'a> Neg for &'a Scalar

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

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

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

impl<T: Scalar + ClosedNeg, const D: usize> Neg for Point<T, D>

impl<'a, T: Scalar + ClosedNeg, const D: usize> Neg for &'a Point<T, D>

impl<T: SimdRealField> Neg for Quaternion<T>where
    T::Element: SimdRealField,

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

impl<T: SimdRealField> Neg for DualQuaternion<T>where
    T::Element: SimdRealField,

impl<'a, T: SimdRealField> Neg for &'a DualQuaternion<T>where
    T::Element: SimdRealField,

impl<T: SimdRealField> Neg for UnitDualQuaternion<T>where
    T::Element: SimdRealField,

impl<'a, T: SimdRealField> Neg for &'a UnitDualQuaternion<T>where
    T::Element: SimdRealField,

impl Neg for TimeSpec

impl Neg for TimeVal

impl Neg for Sign

impl Neg for BigInt

impl<'a> Neg for &'a BigInt

impl Neg for BigUint

impl<'a> Neg for &'a BigUint

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<T: Float> Neg for OrderedFloat<T>

impl<T: Float> Neg for NotNan<T>

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 FixedI64

impl Neg for FixedU64

impl Neg for FixedI128

impl Neg for FixedU128

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,

impl Neg for &JsValue

impl Neg for JsValue

impl Neg for F32

impl Neg for F64