Hi,
As I understand, chaining inequality operators like <, >, <= and >= is not allowed. Yet trying to do so will ask you to add parenthesies:
fn main() {
let x = 2;
if 1 <= x <= 3 {
println!("yes");
} else {
println!("no");
}
}
Gives:
error: chained comparison operators require parentheses
--> src/main.rs:4:10
|
4 | if 1 <= x <= 3 {
| ^^^^^^^
error[E0308]: mismatched types
--> src/main.rs:4:18
|
4 | if 1 <= x <= 3 {
| ^ expected bool, found integer
|
= note: expected type `bool`
found type `{integer}`
The first error is false advice in the context of <=. It would have been ok for == though.
Thanks :)
Hi,
As I understand, chaining inequality operators like
<,>,<=and>=is not allowed. Yet trying to do so will ask you to add parenthesies:Gives:
The first error is false advice in the context of
<=. It would have been ok for==though.Thanks :)