Trait core::ops::Not [] [src]

pub trait Not {
    type Output;
    fn not(self) -> Self::Output;
}

The Not`Nottrait is used to specify the functionality of unary` trait is used to specify the functionality of unary !`!`.

Examples

A trivial implementation of Not`Not. When`. When !Foo`!Foohappens, it ends up calling` happens, it ends up calling not`not, and therefore,`, and therefore, main`mainprints` prints Not-ing!`Not-ing!`.

use std::ops::Not; #[derive(Copy, Clone)] struct Foo; impl Not for Foo { type Output = Foo; fn not(self) -> Foo { println!("Not-ing!"); self } } fn main() { !Foo; }
use std::ops::Not;

#[derive(Copy, Clone)]
struct Foo;

impl Not for Foo {
    type Output = Foo;

    fn not(self) -> Foo {
        println!("Not-ing!");
        self
    }
}

fn main() {
    !Foo;
}

Associated Types

type Output

The resulting type after applying the !`!` operator

Required Methods

fn not(self) -> Self::Output

The method for the unary !`!` operator

Implementors