Trait std::ops::BitOr [] [src]

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

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

Examples

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

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

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

impl BitOr for Foo {
    type Output = Foo;

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

fn main() {
    Foo | Foo;
}

Associated Types

type Output

The resulting type after applying the |`|` operator

Required Methods

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

The method for the |`|` operator

Implementors