Skip to main content

Not

Trait Not 

1.0.0 (const: unstable) · Source
pub trait Not {
    type Output;

    // Required method
    fn not(self) -> Self::Output;
}
Available on crate features crypto and std only.
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.

use std::ops::Not;

#[derive(Debug, PartialEq)]
enum Answer {
    Yes,
    No,
}

impl Not for Answer {
    type Output = Self;

    fn not(self) -> Self::Output {
        match self {
            Answer::Yes => Answer::No,
            Answer::No => Answer::Yes
        }
    }
}

assert_eq!(!Answer::Yes, Answer::No);
assert_eq!(!Answer::No, Answer::Yes);

Required Associated Types§

1.0.0 (const: unstable) · Source

type Output

The resulting type after applying the ! operator.

Required Methods§

1.0.0 (const: unstable) · Source

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".

Implementors§

1.60.0 (const: unstable) · Source§

impl Not for !

Source§

impl Not for &BigInt

1.75.0 (const: unstable) · Source§

impl Not for &Ipv4Addr

1.75.0 (const: unstable) · Source§

impl Not for &Ipv6Addr

1.74.0 (const: unstable) · Source§

impl Not for &Saturating<i8>

1.74.0 (const: unstable) · Source§

impl Not for &Saturating<i16>

1.74.0 (const: unstable) · Source§

impl Not for &Saturating<i32>

1.74.0 (const: unstable) · Source§

impl Not for &Saturating<i64>

1.74.0 (const: unstable) · Source§

impl Not for &Saturating<i128>

1.74.0 (const: unstable) · Source§

impl Not for &Saturating<isize>

1.74.0 (const: unstable) · Source§

impl Not for &Saturating<u8>

1.74.0 (const: unstable) · Source§

impl Not for &Saturating<u16>

1.74.0 (const: unstable) · Source§

impl Not for &Saturating<u32>

1.74.0 (const: unstable) · Source§

impl Not for &Saturating<u64>

1.74.0 (const: unstable) · Source§

impl Not for &Saturating<u128>

1.74.0 (const: unstable) · Source§

impl Not for &Saturating<usize>

1.14.0 (const: unstable) · Source§

impl Not for &Wrapping<i8>

1.14.0 (const: unstable) · Source§

impl Not for &Wrapping<i16>

1.14.0 (const: unstable) · Source§

impl Not for &Wrapping<i32>

1.14.0 (const: unstable) · Source§

impl Not for &Wrapping<i64>

1.14.0 (const: unstable) · Source§

impl Not for &Wrapping<i128>

1.14.0 (const: unstable) · Source§

impl Not for &Wrapping<isize>

1.14.0 (const: unstable) · Source§

impl Not for &Wrapping<u8>

1.14.0 (const: unstable) · Source§

impl Not for &Wrapping<u16>

1.14.0 (const: unstable) · Source§

impl Not for &Wrapping<u32>

1.14.0 (const: unstable) · Source§

impl Not for &Wrapping<u64>

1.14.0 (const: unstable) · Source§

impl Not for &Wrapping<u128>

1.14.0 (const: unstable) · Source§

impl Not for &Wrapping<usize>

1.0.0 (const: unstable) · Source§

impl Not for &bool

1.0.0 (const: unstable) · Source§

impl Not for &i8

1.0.0 (const: unstable) · Source§

impl Not for &i16

1.0.0 (const: unstable) · Source§

impl Not for &i32

1.0.0 (const: unstable) · Source§

impl Not for &i64

1.0.0 (const: unstable) · Source§

impl Not for &i128

1.0.0 (const: unstable) · Source§

impl Not for &isize

1.0.0 (const: unstable) · Source§

impl Not for &u8

1.0.0 (const: unstable) · Source§

impl Not for &u16

1.0.0 (const: unstable) · Source§

impl Not for &u32

1.0.0 (const: unstable) · Source§

impl Not for &u64

1.0.0 (const: unstable) · Source§

impl Not for &u128

1.0.0 (const: unstable) · Source§

impl Not for &usize

§

impl Not for Access

§

type Output = Access

§

impl Not for AsciiSet

§

impl Not for AtFlags

§

type Output = AtFlags

Source§

impl Not for B0

Not of 0 (!0 = 1)

Source§

impl Not for B1

Not of 1 (!1 = 0)

Source§

impl Not for BigInt

§

impl Not for Choice

§

type Output = Choice

Source§

impl Not for subtle::Choice

§

impl Not for CreateFlags

§

type Output = CreateFlags

§

impl Not for DupFlags

§

type Output = DupFlags

§

impl Not for FallocateFlags

§

type Output = FallocateFlags

§

impl Not for FdFlags

§

type Output = FdFlags

§

impl Not for FloatingPointEmulationControl

§

type Output = FloatingPointEmulationControl

§

impl Not for FloatingPointExceptionMode

§

type Output = FloatingPointExceptionMode

§

impl Not for GreaseLists

§

impl Not for IFlags

§

type Output = IFlags

§

impl Not for Ieee16

§

type Output = Ieee16

§

impl Not for Ieee32

§

type Output = Ieee32

§

impl Not for Ieee64

§

type Output = Ieee64

§

impl Not for Ieee128

§

type Output = Ieee128

§

impl Not for InterfaceFlags

§

impl Not for IpScopes

1.75.0 (const: unstable) · Source§

impl Not for Ipv4Addr

1.75.0 (const: unstable) · Source§

impl Not for Ipv6Addr

§

impl Not for MapFlags

§

type Output = MapFlags

§

impl Not for MemfdFlags

§

type Output = MemfdFlags

§

impl Not for MlockAllFlags

§

type Output = MlockAllFlags

§

impl Not for MlockFlags

§

type Output = MlockFlags

§

impl Not for Mode

§

type Output = Mode

§

impl Not for MprotectFlags

§

type Output = MprotectFlags

§

impl Not for MremapFlags

§

type Output = MremapFlags

§

impl Not for MsyncFlags

§

type Output = MsyncFlags

§

impl Not for OFlags

§

type Output = OFlags

§

impl Not for PidfdFlags

§

type Output = PidfdFlags

§

impl Not for PidfdGetfdFlags

§

type Output = PidfdGetfdFlags

§

impl Not for ProtFlags

§

type Output = ProtFlags

§

impl Not for ReadFlags

§

type Output = ReadFlags

§

impl Not for ReadWriteFlags

§

type Output = ReadWriteFlags

§

impl Not for RenameFlags

§

type Output = RenameFlags

§

impl Not for ResolveFlags

§

type Output = ResolveFlags

1.74.0 (const: unstable) · Source§

impl Not for Saturating<i8>

1.74.0 (const: unstable) · Source§

impl Not for Saturating<i16>

1.74.0 (const: unstable) · Source§

impl Not for Saturating<i32>

1.74.0 (const: unstable) · Source§

impl Not for Saturating<i64>

1.74.0 (const: unstable) · Source§

impl Not for Saturating<i128>

1.74.0 (const: unstable) · Source§

impl Not for Saturating<isize>

1.74.0 (const: unstable) · Source§

impl Not for Saturating<u8>

1.74.0 (const: unstable) · Source§

impl Not for Saturating<u16>

1.74.0 (const: unstable) · Source§

impl Not for Saturating<u32>

1.74.0 (const: unstable) · Source§

impl Not for Saturating<u64>

1.74.0 (const: unstable) · Source§

impl Not for Saturating<u128>

1.74.0 (const: unstable) · Source§

impl Not for Saturating<usize>

§

impl Not for SealFlags

§

type Output = SealFlags

§

impl Not for SegmentFlags

§

type Output = SegmentFlags

§

impl Not for ServeDirHiddenKinds

§

impl Not for ShutdownState

§

impl Not for Side

§

type Output = Side

§

impl Not for SpeculationFeatureControl

§

type Output = SpeculationFeatureControl

§

impl Not for SpeculationFeatureState

§

type Output = SpeculationFeatureState

§

impl Not for SslMode

§

impl Not for SslOptions

§

impl Not for SslSessionCacheMode

§

impl Not for SslVerifyMode

§

impl Not for StatVfsMountFlags

§

type Output = StatVfsMountFlags

§

impl Not for StatxAttributes

§

type Output = StatxAttributes

§

impl Not for StatxFlags

§

type Output = StatxFlags

§

impl Not for SymbolFlags

§

type Output = SymbolFlags

§

impl Not for TraceFlags

§

impl Not for UnalignedAccessControl

§

type Output = UnalignedAccessControl

§

impl Not for UserfaultfdFlags

§

type Output = UserfaultfdFlags

§

impl Not for WaitIdOptions

§

type Output = WaitIdOptions

§

impl Not for WaitOptions

§

type Output = WaitOptions

§

impl Not for WasmFeatures

§

type Output = WasmFeatures

§

impl Not for WatchFlags

§

type Output = WatchFlags

1.0.0 (const: unstable) · Source§

impl Not for Wrapping<i8>

1.0.0 (const: unstable) · Source§

impl Not for Wrapping<i16>

1.0.0 (const: unstable) · Source§

impl Not for Wrapping<i32>

1.0.0 (const: unstable) · Source§

impl Not for Wrapping<i64>

1.0.0 (const: unstable) · Source§

impl Not for Wrapping<i128>

1.0.0 (const: unstable) · Source§

impl Not for Wrapping<isize>

1.0.0 (const: unstable) · Source§

impl Not for Wrapping<u8>

1.0.0 (const: unstable) · Source§

impl Not for Wrapping<u16>

1.0.0 (const: unstable) · Source§

impl Not for Wrapping<u32>

1.0.0 (const: unstable) · Source§

impl Not for Wrapping<u64>

1.0.0 (const: unstable) · Source§

impl Not for Wrapping<u128>

1.0.0 (const: unstable) · Source§

impl Not for Wrapping<usize>

§

impl Not for X509CheckFlags

§

impl Not for X509VerifyFlags

§

impl Not for XattrFlags

§

type Output = XattrFlags

1.0.0 (const: unstable) · Source§

impl Not for bool

1.0.0 (const: unstable) · Source§

impl Not for i8

1.0.0 (const: unstable) · Source§

impl Not for i16

1.0.0 (const: unstable) · Source§

impl Not for i32

1.0.0 (const: unstable) · Source§

impl Not for i64

1.0.0 (const: unstable) · Source§

impl Not for i128

1.0.0 (const: unstable) · Source§

impl Not for isize

1.0.0 (const: unstable) · Source§

impl Not for u8

1.0.0 (const: unstable) · Source§

impl Not for u16

1.0.0 (const: unstable) · Source§

impl Not for u32

1.0.0 (const: unstable) · Source§

impl Not for u64

1.0.0 (const: unstable) · Source§

impl Not for u128

1.0.0 (const: unstable) · Source§

impl Not for usize

§

impl<O> Not for I16<O>

§

type Output = I16<O>

§

impl<O> Not for I32<O>

§

type Output = I32<O>

§

impl<O> Not for I64<O>

§

type Output = I64<O>

§

impl<O> Not for I128<O>

§

type Output = I128<O>

§

impl<O> Not for Isize<O>

§

type Output = Isize<O>

§

impl<O> Not for U16<O>

§

type Output = U16<O>

§

impl<O> Not for U32<O>

§

type Output = U32<O>

§

impl<O> Not for U64<O>

§

type Output = U64<O>

§

impl<O> Not for U128<O>

§

type Output = U128<O>

§

impl<O> Not for Usize<O>

§

type Output = Usize<O>

Source§

impl<T, const N: usize> Not for Mask<T, N>
where T: MaskElement,

Source§

type Output = Mask<T, N>

Source§

impl<const N: usize> Not for Simd<i8, N>
where i8: SimdElement,

Source§

impl<const N: usize> Not for Simd<i16, N>

Source§

impl<const N: usize> Not for Simd<i32, N>

Source§

impl<const N: usize> Not for Simd<i64, N>

Source§

impl<const N: usize> Not for Simd<isize, N>

Source§

impl<const N: usize> Not for Simd<u8, N>
where u8: SimdElement,

Source§

impl<const N: usize> Not for Simd<u16, N>

Source§

impl<const N: usize> Not for Simd<u32, N>

Source§

impl<const N: usize> Not for Simd<u64, N>

Source§

impl<const N: usize> Not for Simd<usize, N>