이 페이지는 아직 한국어로 제공되지 않습니다. 번역 작업 중입니다. 현재 번역 프로젝트에 대한 질문이나 피드백이 있으신 경우 언제든지 연락주시기 바랍니다.
Metadata
ID:rust-code-quality/needless-bool
Language: Rust
Severity: Warning
Category: Code Style
Description
An if/else expression that returns true in one branch and false in
the other is equivalent to the condition itself (or its negation). The
boolean literal branches are redundant and add noise without adding clarity.
How to remediate?
Replace the if/else with the condition directly:
// Before
ifx>0{true}else{false}// After
x>0// Before
ifx>0{false}else{true}// After
!(x>0)