望着list of bitwise operators in the Rust Book,我没有看到一个(在C像~
)NOT操作。有没有不运营商锈?
该!
operator用于许多原始类型实现,并且它等同于C的操作者~
参见该示例(playground):
let x = 0b10101010u8;
let y = !x;
println!("x: {:0>8b}", x);
println!("y: {:0>8b}", y);
输出:
x: 10101010 y: 01010101
也可以看看: