BitXor
trait BitXor<T>
Source: compiler/src/builtin_docs/prelude/ops.hy The bitwise XOR operator ^.
a ^ b on a type with a BitXor instance calls bitxor(a, b). int
and byte have builtin instances.
Required methods#
| Name | Description |
|---|---|
bitxor | Returns the bitwise XOR of a and b. |
Examples#
use tests::assert;
class Flags {
pub bits: int,
}
impl BitXor for Flags {
pub fn bitxor(Flags a, Flags b) -> Flags {
return new Flags(a.bits ^ b.bits);
}
}
fn main() {
let f = new Flags(6) ^ new Flags(3);
assert!(f.bits == 5);
}