Trait elliptic_curve::ops::Neg
1.0.0 · source · [−]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);
Associated Types
Required methods
Implementations on Foreign Types
type Output = Saturating<i64>
type Output = Saturating<i8>
type Output = Saturating<i128>
type Output = Saturating<isize>
impl<const LANES: usize> Neg for Simd<i64, LANES> where
i64: SimdElement,
LaneCount<LANES>: SupportedLaneCount,
impl<const LANES: usize> Neg for Simd<i64, LANES> where
i64: SimdElement,
LaneCount<LANES>: SupportedLaneCount,
type Output = Saturating<i32>
type Output = Saturating<i16>
impl<const LANES: usize> Neg for Simd<f32, LANES> where
f32: SimdElement,
LaneCount<LANES>: SupportedLaneCount,
impl<const LANES: usize> Neg for Simd<f32, LANES> where
f32: SimdElement,
LaneCount<LANES>: SupportedLaneCount,
impl<const LANES: usize> Neg for Simd<i8, LANES> where
i8: SimdElement,
LaneCount<LANES>: SupportedLaneCount,
impl<const LANES: usize> Neg for Simd<i8, LANES> where
i8: SimdElement,
LaneCount<LANES>: SupportedLaneCount,
impl<const LANES: usize> Neg for Simd<i32, LANES> where
i32: SimdElement,
LaneCount<LANES>: SupportedLaneCount,
impl<const LANES: usize> Neg for Simd<i32, LANES> where
i32: SimdElement,
LaneCount<LANES>: SupportedLaneCount,
impl<const LANES: usize> Neg for Simd<isize, LANES> where
isize: SimdElement,
LaneCount<LANES>: SupportedLaneCount,
impl<const LANES: usize> Neg for Simd<isize, LANES> where
isize: SimdElement,
LaneCount<LANES>: SupportedLaneCount,
impl<const LANES: usize> Neg for Simd<f64, LANES> where
f64: SimdElement,
LaneCount<LANES>: SupportedLaneCount,
impl<const LANES: usize> Neg for Simd<f64, LANES> where
f64: SimdElement,
LaneCount<LANES>: SupportedLaneCount,
impl<const LANES: usize> Neg for Simd<i16, LANES> where
i16: SimdElement,
LaneCount<LANES>: SupportedLaneCount,
impl<const LANES: usize> Neg for Simd<i16, LANES> where
i16: SimdElement,
LaneCount<LANES>: SupportedLaneCount,
-NInt = PInt
-PInt = NInt