Trait std::ops::BitXorAssign

pub trait BitXorAssign<Rhs = Self> {
    fn bitxor_assign(&mut self, rhs: Rhs);
}

The bitwise XOR assignment operator ^=.

Examples

use std::ops::BitXorAssign;

#[derive(Debug, PartialEq)]
struct Personality {
    has_soul: bool,
    likes_knitting: bool,
}

impl BitXorAssign for Personality {
    fn bitxor_assign(&mut self, rhs: Self) {
        self.has_soul ^= rhs.has_soul;
        self.likes_knitting ^= rhs.likes_knitting;
    }
}

let mut personality = Personality { has_soul: false, likes_knitting: true };
personality ^= Personality { has_soul: true, likes_knitting: true };
assert_eq!(personality, Personality { has_soul: true, likes_knitting: false});

Required methods

Performs the ^= operation.

Examples

let mut x = true;
x ^= false;
assert_eq!(x, true);

let mut x = true;
x ^= true;
assert_eq!(x, false);

let mut x: u8 = 5;
x ^= 1;
assert_eq!(x, 4);

let mut x: u8 = 5;
x ^= 2;
assert_eq!(x, 7);

Implementors

© 2010 The Rust Project Developers
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.
https://doc.rust-lang.org/std/ops/trait.BitXorAssign.html