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