什么是铁锈的按位NOT运算符?

问题描述 投票:18回答:1

望着list of bitwise operators in the Rust Book,我没有看到一个(在C像~)NOT操作。有没有不运营商锈?

rust operators
1个回答
23
投票

! operator用于许多原始类型实现,并且它等同于C的操作者~参见该示例(playground):

let x = 0b10101010u8;
let y = !x;
println!("x: {:0>8b}", x);
println!("y: {:0>8b}", y);

输出:

x: 10101010
y: 01010101

也可以看看:

© www.soinside.com 2019 - 2024. All rights reserved.