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

pub trait BitOr<RHS = Self> {
    type Output;
    fn bitor(self, rhs: RHS) -> <Self as BitOr<RHS>>::Output;
}

The BitOr trait is used to specify the functionality of |.

Example

A trivial implementation of BitOr. When Foo | Foo happens, it ends up calling bitor, and therefore, main prints Bitwise Or-ing!.

#![feature(associated_types)] use std::ops::BitOr; #[derive(Copy)] struct Foo; impl BitOr for Foo { type Output = Foo; fn bitor(self, _rhs: Foo) -> Foo { println!("Bitwise Or-ing!"); self } } fn main() { Foo | Foo; }
#![feature(associated_types)]

use std::ops::BitOr;

#[derive(Copy)]
struct Foo;

impl BitOr for Foo {
    type Output = Foo;

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

fn main() {
    Foo | Foo;
}

Required Methods

type Output

fn bitor(self, rhs: RHS) -> <Self as BitOr<RHS>>::Output

The method for the | operator

Implementors