October 2018
Beginner
180 pages
4h 48m
English
The BitXorAssign trait enables the ^= operator for data types that implement it.
Implementing BitXorAssign looks like this:
pub enum BitExample { Yes, No,}impl BitXorAssign for BitExample { fn bitxor_assign(&mut self, other: BitExample) { *self = match (&self, other) { (BitExample::Yes, BitExample::Yes) => BitExample::No, (BitExample::No, BitExample::Yes) => BitExample::Yes, (BitExample::Yes, BitExample::No) => BitExample::Yes, (BitExample::No, BitExample::No) => BitExample::No, }; }}
Read now
Unlock full access