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