~
.
pub trait BitNot
BitNot
for a wrapper around u8
.
use core::traits::BitNot;
#[derive(Drop, PartialEq)]
struct Wrapper {
u8: u8,
}
impl BitNotWrapper of BitNot {
fn bitnot(a: Wrapper) -> Wrapper {
Wrapper { u8: ~a.u8 }
}
}
assert!(~Wrapper { u8: 0 } == Wrapper { u8 : 255 });
assert!(~Wrapper { u8: 1 } == Wrapper { u8 : 254 });
~
operation.
fn bitnot(a: T) -> T
assert!(~1_u8 == 254);
Was this page helpful?