Trait std::ops::BitAndStable [-] [+] [src]

pub trait BitAnd<RHS = Self> where <Self as BitAnd<RHS>>::Output: Sized {
    type Output;

    fn bitand(self, rhs: RHS) -> <Self as BitAnd<RHS>>::Output;
}

The BitAnd trait is used to specify the functionality of &.

Example

A trivial implementation of BitAnd. When Foo & Foo happens, it ends up calling bitand, and therefore, main prints Bitwise And-ing!.

use std::ops::BitAnd; #[derive(Copy)] struct Foo; impl BitAnd for Foo { type Output = Foo; fn bitand(self, _rhs: Foo) -> Foo { println!("Bitwise And-ing!"); self } } fn main() { Foo & Foo; }
use std::ops::BitAnd;

#[derive(Copy)]
struct Foo;

impl BitAnd for Foo {
    type Output = Foo;

    fn bitand(self, _rhs: Foo) -> Foo {
        println!("Bitwise And-ing!");
        self
    }
}

fn main() {
    Foo & Foo;
}

Associated Types

type Output

Required Methods

fn bitand(self, rhs: RHS) -> <Self as BitAnd<RHS>>::Output

The method for the & operator

Implementors