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

pub trait BitAnd<RHS = Self> {
    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!.

#![feature(associated_types)] 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; }
#![feature(associated_types)]

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;
}

Required Methods

type Output

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

The method for the & operator

Implementors