【发布时间】:2016-08-11 12:16:20
【问题描述】:
查看list of bitwise operators in the Rust Book,我没有看到NOT 运算符(如C 中的~)。 Rust 中没有 NOT 运算符吗?
【问题讨论】:
查看list of bitwise operators in the Rust Book,我没有看到NOT 运算符(如C 中的~)。 Rust 中没有 NOT 运算符吗?
【问题讨论】:
! operator 是为许多基本类型实现的,它等效于 C 中的 ~ 运算符。请参阅此示例 (playground):
let x = 0b10101010u8;
let y = !x;
println!("x: {:0>8b}", x);
println!("y: {:0>8b}", y);
输出:
x: 10101010 y: 01010101
另见:
【讨论】: