Trait core::ops::BitAndAssign [] [src]

pub trait BitAndAssign<Rhs = Self> {
    fn bitand_assign(&mut self, Rhs);
}
Unstable (op_assign_traits #28235)

: recently added

The BitAndAssign trait is used to specify the functionality of &=.

Examples

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

#![feature(augmented_assignments)] #![feature(op_assign_traits)] use std::ops::BitAndAssign; struct Foo; impl BitAndAssign for Foo { fn bitand_assign(&mut self, _rhs: Foo) { println!("Bitwise And-ing!"); } } #[allow(unused_assignments)] fn main() { let mut foo = Foo; foo &= Foo; }
#![feature(augmented_assignments)]
#![feature(op_assign_traits)]

use std::ops::BitAndAssign;

struct Foo;

impl BitAndAssign for Foo {
    fn bitand_assign(&mut self, _rhs: Foo) {
        println!("Bitwise And-ing!");
    }
}

fn main() {
    let mut foo = Foo;
    foo &= Foo;
}

Required Methods

fn bitand_assign(&mut self, Rhs)

Unstable (op_assign_traits #28235)

: recently added

The method for the & operator

Implementors