pub trait Not {
type Output;
// Required method
fn not(self) -> Self::Output;
}Expand description
The unary negation operator !. It performs either logical or bitwise negation,
depending on the type.
§Examples
An implementation of Not for Answer, which enables the use of ! to
invert its value.
Required Associated Types§
Required Methods§
1.0.0 (const: unstable) · Sourcefn not(self) -> Self::Output
fn not(self) -> Self::Output
Performs the unary ! operation using logical or bitwise negation.
§Examples
// Logical negation changes between true and false:
assert_eq!(!true, false);
assert_eq!(!false, true);
// Bitwise negation changes between 0 and 1 in the binary
// representation of integers:
assert_eq!(!1u8, 254);
assert_eq!(!0u8, 255);
// The same examples, represented in binary:
assert_eq!(!0b0000_0001u8, 0b1111_1110);
assert_eq!(!0b0000_0000u8, 0b1111_1111);Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".