用法
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;
}
}
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});
相关用法
- Rust std::ops::BitXorAssign.bitxor_assign用法及代码示例
- Rust std::ops::BitXor用法及代码示例
- Rust std::ops::BitAndAssign用法及代码示例
- Rust std::ops::BitOrAssign用法及代码示例
- Rust std::ops::BitAnd用法及代码示例
- Rust std::ops::BitOrAssign.bitor_assign用法及代码示例
- Rust std::ops::BitAndAssign.bitand_assign用法及代码示例
- Rust std::ops::BitAnd.bitand用法及代码示例
- Rust std::ops::BitOr用法及代码示例
- Rust std::ops::Bound.cloned用法及代码示例
- Rust std::ops::Bound.map用法及代码示例
- Rust std::ops::Bound用法及代码示例
- Rust std::ops::Shl用法及代码示例
- Rust std::ops::RangeInclusive.end用法及代码示例
- Rust std::ops::DivAssign用法及代码示例
- Rust std::ops::Try.from_output用法及代码示例
注:本文由纯净天空筛选整理自rust-lang.org大神的英文原创作品 Trait std::ops::BitXorAssign。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。