Trait snarkvm_circuit::environment::prelude::Neg
1.0.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§
Required Methods§
Trait Implementations§
§impl<E, I> Metrics<dyn Neg<Output = Integer<E, I>>> for Integer<E, I>where
E: Environment,
I: IntegerType,
impl<E, I> Metrics<dyn Neg<Output = Integer<E, I>>> for Integer<E, I>where E: Environment, I: IntegerType,
§impl<E> OutputMode<dyn Neg<Output = Field<E>>> for Field<E>where
E: Environment,
impl<E> OutputMode<dyn Neg<Output = Field<E>>> for Field<E>where E: Environment,
§impl<E> OutputMode<dyn Neg<Output = Group<E>>> for Group<E>where
E: Environment,
impl<E> OutputMode<dyn Neg<Output = Group<E>>> for Group<E>where E: Environment,
§impl<E, I> OutputMode<dyn Neg<Output = Integer<E, I>>> for Integer<E, I>where
E: Environment,
I: IntegerType,
impl<E, I> OutputMode<dyn Neg<Output = Integer<E, I>>> for Integer<E, I>where E: Environment, I: IntegerType,
type Case = Mode
§fn output_mode(
case: &<Integer<E, I> as OutputMode<dyn Neg<Output = Integer<E, I>>>>::Case
) -> Mode
fn output_mode( case: &<Integer<E, I> as OutputMode<dyn Neg<Output = Integer<E, I>>>>::Case ) -> Mode
Returns the mode of the output.