3 ms·
No, as assignment always results in (), and if always requires a boolean. This is by design.
by steveklabnik 10y ago
No, as assignment always results in (), and if always requires a boolean. This is by design.
- tyingq 10y agoAh...so this works: fn main() { let mut x = false; println!("{}", x); if {x=true;x} { println!("{}", x); } } But stands out as pretty obvious. Not something you might easily sneak into a codebase.
- steveklabnik 10y agoSneaky! Yeah, no way this should get past code review, and not even easy to accidentally type.