[英]What is the bitwise NOT operator in Rust?
Looking at the list of bitwise operators in the Rust Book , I don't see a NOT operator (like ~
in C). 查看Rust Book中的按位运算符列表 ,我没有看到NOT运算符(如C中的~
)。 Is there no NOT operator in Rust? Rust中没有NOT运算符吗?
The !
的!
operator is implemented for many primitive types and it's equivalent to the ~
operator in C. See this example ( playground ): operator是针对许多原始类型实现的,它等同于C中的~
运算符。请参阅此示例( playground ):
let x = 0b10101010u8;
let y = !x;
println!("x: {:0>8b}", x);
println!("y: {:0>8b}", y);
Outputs: 输出:
x: 10101010 y: 01010101
See also: 也可以看看:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.