Closed
Description
What it does
Instead of using an if statement to convert a bool to an int, this lint suggests using a coercion or a from()
function.
Lint Name
bool_to_int_with_if
Category
style
Advantage
- Makes code more concise
- Makes this conversion more discoverable
Drawbacks
- None
Example
if condition {
1_i64
} else {
0
}
Could be written as:
i64::from(condition)
or
condition as i64