G.TYP.BOL.01 不应将布尔值和布尔字面量进行比较
【级别】 要求
【描述】
在 Rust 中,返回为布尔值的表达式或函数值可以直接当作布尔值使用。
总之,使用布尔表达式的时候,要尽可能地简洁明了。
【反例】
【正例】
【Lint 检测】
lint name | Clippy 可检测 | Rustc 可检测 | Lint Group | level |
---|---|---|---|---|
bool_comparison | yes | no | complexity | warn |
bool_assert_comparison | yes | no | style | warn |
needless_bool | yes | no | complexity | warn |
nonminimal_bool | yes | no | complexity | warn |
needless_bitwise_bool | yes | no | pedantic | allow |
assertions_on_constants | yes | no | pedantic | warn |