Use Expressions
if
, match
, loop
, for
, while
, etc. are all expressions in Rust that evaluate to a value.
Don't write:
fn main() { let condition = true; let assignment; if condition { assignment = true; } else { assignment = false; } }
Do write:
fn main() { let condition = true; let assignment = if condition { true } else { false }; }