Rust for Python Developers - Operators
Shin_O
51.9K views
This article was originally published on Medium
Follow me:
Logical Operators
Rust logical operator symbols are different from Python ones.
Meaning | Python | Rust |
---|---|---|
True if both the operands are true | and | && |
True if either of the operands is true | or | || |
True if operand is false | not | ! |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
fn main() {
let a = true;
let b = false;
let c = !a;
let d = a && b;
let e = a || b;
println!("
a: {}, b: {},
c: !{0} is {},
d: {0} && {1} is {},
e: {0} || {1} is {}",
a, b, c, d, e);
}
Create your playground on Tech.io
This playground was created on Tech.io, our hands-on, knowledge-sharing platform for developers.