BitXorAssign
BitXorAssign (비트 XOR 대입 연산자 트레이트)
비트 XOR 대입 연산자 ^=를 위한 트레이트예요.
출처: Rust 공식 문서
본문
Rhs는 기본적으로 Self이지만, 이것이 필수는 아니에요.
pub trait BitXorAssign<Rhs = Self> {
// 필수 메서드
fn bitxor_assign(&mut self, rhs: Rhs);
}
예시
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;
}
}