core::ops

Trait Not

1.0.0 · source
pub trait Not {
    type Output;

    // Required method
    fn not(self) -> Self::Output;
}
Expand description

The unary logical negation operator !.

§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 · source

type Output

The resulting type after applying the ! operator.

Required Methods§

1.0.0 · source

fn not(self) -> Self::Output

Performs the unary ! operation.

§Examples
assert_eq!(!true, false);
assert_eq!(!false, true);
assert_eq!(!1u8, 254);
assert_eq!(!0u8, 255);

Implementors§

1.0.0 · source§

impl Not for &bool

1.0.0 · source§

impl Not for &i8

1.0.0 · source§

impl Not for &i16

1.0.0 · source§

impl Not for &i32

1.0.0 · source§

impl Not for &i64

1.0.0 · source§

impl Not for &i128

1.0.0 · source§

impl Not for &isize

1.0.0 · source§

impl Not for &u8

1.0.0 · source§

impl Not for &u16

1.0.0 · source§

impl Not for &u32

1.0.0 · source§

impl Not for &u64

1.0.0 · source§

impl Not for &u128

1.0.0 · source§

impl Not for &usize

1.75.0 · source§

impl Not for &Ipv4Addr

1.75.0 · source§

impl Not for &Ipv6Addr

1.74.0 · source§

impl Not for &Saturating<i8>

1.74.0 · source§

impl Not for &Saturating<i16>

1.74.0 · source§

impl Not for &Saturating<i32>

1.74.0 · source§

impl Not for &Saturating<i64>

1.74.0 · source§

impl Not for &Saturating<i128>

1.74.0 · source§

impl Not for &Saturating<isize>

1.74.0 · source§

impl Not for &Saturating<u8>

1.74.0 · source§

impl Not for &Saturating<u16>

1.74.0 · source§

impl Not for &Saturating<u32>

1.74.0 · source§

impl Not for &Saturating<u64>

1.74.0 · source§

impl Not for &Saturating<u128>

1.74.0 · source§

impl Not for &Saturating<usize>

1.14.0 · source§

impl Not for &Wrapping<i8>

1.14.0 · source§

impl Not for &Wrapping<i16>

1.14.0 · source§

impl Not for &Wrapping<i32>

1.14.0 · source§

impl Not for &Wrapping<i64>

1.14.0 · source§

impl Not for &Wrapping<i128>

1.14.0 · source§

impl Not for &Wrapping<isize>

1.14.0 · source§

impl Not for &Wrapping<u8>

1.14.0 · source§

impl Not for &Wrapping<u16>

1.14.0 · source§

impl Not for &Wrapping<u32>

1.14.0 · source§

impl Not for &Wrapping<u64>

1.14.0 · source§

impl Not for &Wrapping<u128>

1.14.0 · source§

impl Not for &Wrapping<usize>

1.0.0 · source§

impl Not for bool

1.0.0 · source§

impl Not for i8

1.0.0 · source§

impl Not for i16

1.0.0 · source§

impl Not for i32

1.0.0 · source§

impl Not for i64

1.0.0 · source§

impl Not for i128

1.0.0 · source§

impl Not for isize

1.60.0 · source§

impl Not for !

1.0.0 · source§

impl Not for u8

1.0.0 · source§

impl Not for u16

1.0.0 · source§

impl Not for u32

1.0.0 · source§

impl Not for u64

1.0.0 · source§

impl Not for u128

1.0.0 · source§

impl Not for usize

1.75.0 · source§

impl Not for Ipv4Addr

1.75.0 · source§

impl Not for Ipv6Addr

1.74.0 · source§

impl Not for Saturating<i8>

1.74.0 · source§

impl Not for Saturating<i16>

1.74.0 · source§

impl Not for Saturating<i32>

1.74.0 · source§

impl Not for Saturating<i64>

1.74.0 · source§

impl Not for Saturating<i128>

1.74.0 · source§

impl Not for Saturating<isize>

1.74.0 · source§

impl Not for Saturating<u8>

1.74.0 · source§

impl Not for Saturating<u16>

1.74.0 · source§

impl Not for Saturating<u32>

1.74.0 · source§

impl Not for Saturating<u64>

1.74.0 · source§

impl Not for Saturating<u128>

1.74.0 · source§

impl Not for Saturating<usize>

1.0.0 · source§

impl Not for Wrapping<i8>

1.0.0 · source§

impl Not for Wrapping<i16>

1.0.0 · source§

impl Not for Wrapping<i32>

1.0.0 · source§

impl Not for Wrapping<i64>

1.0.0 · source§

impl Not for Wrapping<i128>

1.0.0 · source§

impl Not for Wrapping<isize>

1.0.0 · source§

impl Not for Wrapping<u8>

1.0.0 · source§

impl Not for Wrapping<u16>

1.0.0 · source§

impl Not for Wrapping<u32>

1.0.0 · source§

impl Not for Wrapping<u64>

1.0.0 · source§

impl Not for Wrapping<u128>

1.0.0 · source§

impl Not for Wrapping<usize>

source§

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

source§

type Output = Mask<T, N>

source§

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

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>

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>