Trait core::ops::BitXorStable [-]  [+] [src]

pub trait BitXor<RHS = Self> {
    type Output;

    fn bitxor(self, rhs: RHS) -> Output;
}

The BitXor trait is used to specify the functionality of ^.

Example

A trivial implementation of BitXor. When Foo ^ Foo happens, it ends up calling bitxor, and therefore, main prints Bitwise Xor-ing!.

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

use std::ops::BitXor;

#[derive(Copy)]
struct Foo;

impl BitXor for Foo {
    type Output = Foo;

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

fn main() {
    Foo ^ Foo;
}

Associated Types

type Output

Required Methods

fn bitxor(self, rhs: RHS) -> Output

The method for the ^ operator

Implementors