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§
1.71.0 (const: unstable) · Source§impl Neg for &NonZero<i8>
Available on non-crate feature ferrocene_certified
only.
impl Neg for &NonZero<i8>
Available on non-crate feature
ferrocene_certified
only.1.71.0 (const: unstable) · Source§impl Neg for &NonZero<i16>
Available on non-crate feature ferrocene_certified
only.
impl Neg for &NonZero<i16>
Available on non-crate feature
ferrocene_certified
only.1.71.0 (const: unstable) · Source§impl Neg for &NonZero<i32>
Available on non-crate feature ferrocene_certified
only.
impl Neg for &NonZero<i32>
Available on non-crate feature
ferrocene_certified
only.1.71.0 (const: unstable) · Source§impl Neg for &NonZero<i64>
Available on non-crate feature ferrocene_certified
only.
impl Neg for &NonZero<i64>
Available on non-crate feature
ferrocene_certified
only.1.71.0 (const: unstable) · Source§impl Neg for &NonZero<i128>
Available on non-crate feature ferrocene_certified
only.
impl Neg for &NonZero<i128>
Available on non-crate feature
ferrocene_certified
only.1.71.0 (const: unstable) · Source§impl Neg for &NonZero<isize>
Available on non-crate feature ferrocene_certified
only.
impl Neg for &NonZero<isize>
Available on non-crate feature
ferrocene_certified
only.1.74.0 (const: unstable) · Source§impl Neg for &Saturating<i8>
Available on non-crate feature ferrocene_certified
only.
impl Neg for &Saturating<i8>
Available on non-crate feature
ferrocene_certified
only.1.74.0 (const: unstable) · Source§impl Neg for &Saturating<i16>
Available on non-crate feature ferrocene_certified
only.
impl Neg for &Saturating<i16>
Available on non-crate feature
ferrocene_certified
only.1.74.0 (const: unstable) · Source§impl Neg for &Saturating<i32>
Available on non-crate feature ferrocene_certified
only.
impl Neg for &Saturating<i32>
Available on non-crate feature
ferrocene_certified
only.1.74.0 (const: unstable) · Source§impl Neg for &Saturating<i64>
Available on non-crate feature ferrocene_certified
only.
impl Neg for &Saturating<i64>
Available on non-crate feature
ferrocene_certified
only.1.74.0 (const: unstable) · Source§impl Neg for &Saturating<i128>
Available on non-crate feature ferrocene_certified
only.
impl Neg for &Saturating<i128>
Available on non-crate feature
ferrocene_certified
only.1.74.0 (const: unstable) · Source§impl Neg for &Saturating<isize>
Available on non-crate feature ferrocene_certified
only.
impl Neg for &Saturating<isize>
Available on non-crate feature
ferrocene_certified
only.1.14.0 (const: unstable) · Source§impl Neg for &Wrapping<i8>
Available on non-crate feature ferrocene_certified
only.
impl Neg for &Wrapping<i8>
Available on non-crate feature
ferrocene_certified
only.1.14.0 (const: unstable) · Source§impl Neg for &Wrapping<i16>
Available on non-crate feature ferrocene_certified
only.
impl Neg for &Wrapping<i16>
Available on non-crate feature
ferrocene_certified
only.1.14.0 (const: unstable) · Source§impl Neg for &Wrapping<i32>
Available on non-crate feature ferrocene_certified
only.
impl Neg for &Wrapping<i32>
Available on non-crate feature
ferrocene_certified
only.1.14.0 (const: unstable) · Source§impl Neg for &Wrapping<i64>
Available on non-crate feature ferrocene_certified
only.
impl Neg for &Wrapping<i64>
Available on non-crate feature
ferrocene_certified
only.1.14.0 (const: unstable) · Source§impl Neg for &Wrapping<i128>
Available on non-crate feature ferrocene_certified
only.
impl Neg for &Wrapping<i128>
Available on non-crate feature
ferrocene_certified
only.1.14.0 (const: unstable) · Source§impl Neg for &Wrapping<isize>
Available on non-crate feature ferrocene_certified
only.
impl Neg for &Wrapping<isize>
Available on non-crate feature
ferrocene_certified
only.1.14.0 (const: unstable) · Source§impl Neg for &Wrapping<u8>
Available on non-crate feature ferrocene_certified
only.
impl Neg for &Wrapping<u8>
Available on non-crate feature
ferrocene_certified
only.1.14.0 (const: unstable) · Source§impl Neg for &Wrapping<u16>
Available on non-crate feature ferrocene_certified
only.
impl Neg for &Wrapping<u16>
Available on non-crate feature
ferrocene_certified
only.1.14.0 (const: unstable) · Source§impl Neg for &Wrapping<u32>
Available on non-crate feature ferrocene_certified
only.
impl Neg for &Wrapping<u32>
Available on non-crate feature
ferrocene_certified
only.1.14.0 (const: unstable) · Source§impl Neg for &Wrapping<u64>
Available on non-crate feature ferrocene_certified
only.
impl Neg for &Wrapping<u64>
Available on non-crate feature
ferrocene_certified
only.1.14.0 (const: unstable) · Source§impl Neg for &Wrapping<u128>
Available on non-crate feature ferrocene_certified
only.
impl Neg for &Wrapping<u128>
Available on non-crate feature
ferrocene_certified
only.1.14.0 (const: unstable) · Source§impl Neg for &Wrapping<usize>
Available on non-crate feature ferrocene_certified
only.
impl Neg for &Wrapping<usize>
Available on non-crate feature
ferrocene_certified
only.Source§impl Neg for core::arch::powerpc::vector_float
Available on PowerPC or PowerPC-64 only.
impl Neg for core::arch::powerpc::vector_float
Available on PowerPC or PowerPC-64 only.
type Output = vector_float
Source§impl Neg for core::arch::powerpc::vector_signed_char
Available on PowerPC or PowerPC-64 only.
impl Neg for core::arch::powerpc::vector_signed_char
Available on PowerPC or PowerPC-64 only.
type Output = vector_signed_char
Source§impl Neg for core::arch::powerpc::vector_signed_int
Available on PowerPC or PowerPC-64 only.
impl Neg for core::arch::powerpc::vector_signed_int
Available on PowerPC or PowerPC-64 only.
type Output = vector_signed_int
Source§impl Neg for core::arch::powerpc::vector_signed_short
Available on PowerPC or PowerPC-64 only.
impl Neg for core::arch::powerpc::vector_signed_short
Available on PowerPC or PowerPC-64 only.
type Output = vector_signed_short
Source§impl Neg for vector_double
Available on s390x only.
impl Neg for vector_double
Available on s390x only.
type Output = vector_double
Source§impl Neg for core::arch::s390x::vector_float
Available on s390x only.
impl Neg for core::arch::s390x::vector_float
Available on s390x only.
type Output = vector_float
Source§impl Neg for core::arch::s390x::vector_signed_char
Available on s390x only.
impl Neg for core::arch::s390x::vector_signed_char
Available on s390x only.
type Output = vector_signed_char
Source§impl Neg for core::arch::s390x::vector_signed_int
Available on s390x only.
impl Neg for core::arch::s390x::vector_signed_int
Available on s390x only.
type Output = vector_signed_int
Source§impl Neg for vector_signed_long_long
Available on s390x only.
impl Neg for vector_signed_long_long
Available on s390x only.
Source§impl Neg for core::arch::s390x::vector_signed_short
Available on s390x only.
impl Neg for core::arch::s390x::vector_signed_short
Available on s390x only.
type Output = vector_signed_short
1.71.0 (const: unstable) · Source§impl Neg for NonZero<i8>
Available on non-crate feature ferrocene_certified
only.
impl Neg for NonZero<i8>
Available on non-crate feature
ferrocene_certified
only.1.71.0 (const: unstable) · Source§impl Neg for NonZero<i16>
Available on non-crate feature ferrocene_certified
only.
impl Neg for NonZero<i16>
Available on non-crate feature
ferrocene_certified
only.1.71.0 (const: unstable) · Source§impl Neg for NonZero<i32>
Available on non-crate feature ferrocene_certified
only.
impl Neg for NonZero<i32>
Available on non-crate feature
ferrocene_certified
only.1.71.0 (const: unstable) · Source§impl Neg for NonZero<i64>
Available on non-crate feature ferrocene_certified
only.
impl Neg for NonZero<i64>
Available on non-crate feature
ferrocene_certified
only.1.71.0 (const: unstable) · Source§impl Neg for NonZero<i128>
Available on non-crate feature ferrocene_certified
only.
impl Neg for NonZero<i128>
Available on non-crate feature
ferrocene_certified
only.1.71.0 (const: unstable) · Source§impl Neg for NonZero<isize>
Available on non-crate feature ferrocene_certified
only.
impl Neg for NonZero<isize>
Available on non-crate feature
ferrocene_certified
only.1.74.0 (const: unstable) · Source§impl Neg for Saturating<i8>
Available on non-crate feature ferrocene_certified
only.
impl Neg for Saturating<i8>
Available on non-crate feature
ferrocene_certified
only.type Output = Saturating<i8>
1.74.0 (const: unstable) · Source§impl Neg for Saturating<i16>
Available on non-crate feature ferrocene_certified
only.
impl Neg for Saturating<i16>
Available on non-crate feature
ferrocene_certified
only.type Output = Saturating<i16>
1.74.0 (const: unstable) · Source§impl Neg for Saturating<i32>
Available on non-crate feature ferrocene_certified
only.
impl Neg for Saturating<i32>
Available on non-crate feature
ferrocene_certified
only.type Output = Saturating<i32>
1.74.0 (const: unstable) · Source§impl Neg for Saturating<i64>
Available on non-crate feature ferrocene_certified
only.
impl Neg for Saturating<i64>
Available on non-crate feature
ferrocene_certified
only.type Output = Saturating<i64>
1.74.0 (const: unstable) · Source§impl Neg for Saturating<i128>
Available on non-crate feature ferrocene_certified
only.
impl Neg for Saturating<i128>
Available on non-crate feature
ferrocene_certified
only.type Output = Saturating<i128>
1.74.0 (const: unstable) · Source§impl Neg for Saturating<isize>
Available on non-crate feature ferrocene_certified
only.
impl Neg for Saturating<isize>
Available on non-crate feature
ferrocene_certified
only.type Output = Saturating<isize>
1.10.0 (const: unstable) · Source§impl Neg for Wrapping<i8>
Available on non-crate feature ferrocene_certified
only.
impl Neg for Wrapping<i8>
Available on non-crate feature
ferrocene_certified
only.1.10.0 (const: unstable) · Source§impl Neg for Wrapping<i16>
Available on non-crate feature ferrocene_certified
only.
impl Neg for Wrapping<i16>
Available on non-crate feature
ferrocene_certified
only.1.10.0 (const: unstable) · Source§impl Neg for Wrapping<i32>
Available on non-crate feature ferrocene_certified
only.
impl Neg for Wrapping<i32>
Available on non-crate feature
ferrocene_certified
only.1.10.0 (const: unstable) · Source§impl Neg for Wrapping<i64>
Available on non-crate feature ferrocene_certified
only.
impl Neg for Wrapping<i64>
Available on non-crate feature
ferrocene_certified
only.1.10.0 (const: unstable) · Source§impl Neg for Wrapping<i128>
Available on non-crate feature ferrocene_certified
only.
impl Neg for Wrapping<i128>
Available on non-crate feature
ferrocene_certified
only.1.10.0 (const: unstable) · Source§impl Neg for Wrapping<isize>
Available on non-crate feature ferrocene_certified
only.
impl Neg for Wrapping<isize>
Available on non-crate feature
ferrocene_certified
only.1.10.0 (const: unstable) · Source§impl Neg for Wrapping<u8>
Available on non-crate feature ferrocene_certified
only.
impl Neg for Wrapping<u8>
Available on non-crate feature
ferrocene_certified
only.1.10.0 (const: unstable) · Source§impl Neg for Wrapping<u16>
Available on non-crate feature ferrocene_certified
only.
impl Neg for Wrapping<u16>
Available on non-crate feature
ferrocene_certified
only.1.10.0 (const: unstable) · Source§impl Neg for Wrapping<u32>
Available on non-crate feature ferrocene_certified
only.
impl Neg for Wrapping<u32>
Available on non-crate feature
ferrocene_certified
only.1.10.0 (const: unstable) · Source§impl Neg for Wrapping<u64>
Available on non-crate feature ferrocene_certified
only.
impl Neg for Wrapping<u64>
Available on non-crate feature
ferrocene_certified
only.1.10.0 (const: unstable) · Source§impl Neg for Wrapping<u128>
Available on non-crate feature ferrocene_certified
only.
impl Neg for Wrapping<u128>
Available on non-crate feature
ferrocene_certified
only.1.10.0 (const: unstable) · Source§impl Neg for Wrapping<usize>
Available on non-crate feature ferrocene_certified
only.
impl Neg for Wrapping<usize>
Available on non-crate feature
ferrocene_certified
only.Source§impl<const N: usize> Neg for Simd<f32, N>
Available on non-crate feature ferrocene_certified
only.
impl<const N: usize> Neg for Simd<f32, N>
Available on non-crate feature
ferrocene_certified
only.Source§impl<const N: usize> Neg for Simd<f64, N>
Available on non-crate feature ferrocene_certified
only.
impl<const N: usize> Neg for Simd<f64, N>
Available on non-crate feature
ferrocene_certified
only.Source§impl<const N: usize> Neg for Simd<i8, N>
Available on non-crate feature ferrocene_certified
only.
impl<const N: usize> Neg for Simd<i8, N>
Available on non-crate feature
ferrocene_certified
only.Source§impl<const N: usize> Neg for Simd<i16, N>
Available on non-crate feature ferrocene_certified
only.
impl<const N: usize> Neg for Simd<i16, N>
Available on non-crate feature
ferrocene_certified
only.Source§impl<const N: usize> Neg for Simd<i32, N>
Available on non-crate feature ferrocene_certified
only.
impl<const N: usize> Neg for Simd<i32, N>
Available on non-crate feature
ferrocene_certified
only.