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§
Required Methods§
Implementors§
source§impl Neg for &starknet_curve::ec_point::AffinePoint
impl Neg for &starknet_curve::ec_point::AffinePoint
type Output = AffinePoint
source§impl Neg for &starknet_types_core::curve::affine_point::AffinePoint
impl Neg for &starknet_types_core::curve::affine_point::AffinePoint
type Output = AffinePoint
source§impl Neg for &ProjectivePoint
impl Neg for &ProjectivePoint
type Output = ProjectivePoint
1.74.0 · source§impl Neg for Saturating<i8>
impl Neg for Saturating<i8>
type Output = Saturating<i8>
1.74.0 · source§impl Neg for Saturating<i16>
impl Neg for Saturating<i16>
type Output = Saturating<i16>
1.74.0 · source§impl Neg for Saturating<i32>
impl Neg for Saturating<i32>
type Output = Saturating<i32>
1.74.0 · source§impl Neg for Saturating<i64>
impl Neg for Saturating<i64>
type Output = Saturating<i64>
1.74.0 · source§impl Neg for Saturating<i128>
impl Neg for Saturating<i128>
type Output = Saturating<i128>
1.74.0 · source§impl Neg for Saturating<isize>
impl Neg for Saturating<isize>
type Output = Saturating<isize>
source§impl Neg for starknet_ff::FieldElement
impl Neg for starknet_ff::FieldElement
type Output = FieldElement
source§impl<F> Neg for &lambdaworks_math::field::element::FieldElement<F>where
F: IsField,
impl<F> Neg for &lambdaworks_math::field::element::FieldElement<F>where
F: IsField,
Negation operator overloading for field elements*/