BitNot
trait BitNot<T>
Source: compiler/src/builtin_docs/prelude/ops.hy The bitwise NOT operator ~x.
~x on a type with a BitNot instance calls bitnot(x). Only int has
a builtin instance (~x is -x - 1); byte does not.
Required methods#
| Name | Description |
|---|---|
bitnot | Returns a with every bit flipped. |
Examples#
use tests::assert;
class Flags {
pub bits: int,
}
impl BitNot for Flags {
pub fn bitnot(Flags a) -> Flags {
return new Flags(~a.bits);
}
}
fn main() {
let f = ~new Flags(0);
assert!(f.bits == -1);
}