BitNot
The bitwise NOT operator ~
. # ExamplesAn implementation of BitNot
for a wrapper around u8
.
use core::traits::BitNot;
[derive(Drop, PartialEq)]
struct Wrapper {
u8: u8,
}
impl BitNotWrapper of BitNot<Wrapper> {
fn bitnot(a: Wrapper) -> Wrapper {
Wrapper { u8: ~a.u8 }
}
}
assert!(~Wrapper { u8: 0 } == Wrapper { u8 : 255 });
assert!(~Wrapper { u8: 1 } == Wrapper { u8 : 254 });
Fully qualified path: core::traits::BitNot
pub trait BitNot<T>
Trait functions
bitnot
Performs the ~
operation. # Examples
assert!(~1_u8 == 254);
Fully qualified path: core::traits::BitNot::bitnot
fn bitnot(a: T) -> T