E0007: Condition is Not a Boolean
The condition in an if or while statement must be a boolean, but you provided a different type.
Example
fn main() {
if 42 { // Error: the if condition must have type `bool`, found `i64`
// ...
}
}
fn main() {
while 1 { // Error: the while condition must have type `bool`, found `i64`
// ...
}
}
How to fix
Use a boolean expression as the condition:
fn main() {
if true {
// ...
}
}
Or use a comparison to produce a boolean:
fn main() {
let x = 42;
if x > 0 {
// ...
}
}