-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
A-lintArea: New lintsArea: New lintsgood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy
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
xFrednet and SadiinsoSnowfalldsherret
Metadata
Metadata
Assignees
Labels
A-lintArea: New lintsArea: New lintsgood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy