3 ms·
You’re correct. Other folks seem to be using non-Rust mental models for semicolons.
by posixplz 7y ago
You’re correct. Other folks seem to be using non-Rust mental models for semicolons.
- masklinn 7y agoNo they're not, see steve's explanation above. Putting a semicolon after an expression makes it into a statement, which are unit-valued, which is why the expression's value gets suppressed. It's a subset of "statements not ending with blocks" (since an expression-statement doesn't take a statement-block even if the expression itself has one).
- asdkhadsj 7y agoBut my comment was in reply to: > no semicolons after things that use {}, semicolons after everything else. Which seems fundamentally flawed for a cheatsheet. Unless you never intend to return anything with a bracket, I guess.