2 ms·
I always thought return, like assignment, could only be a statement and not an expression
by brundolf 6y ago
I always thought return, like assignment, could only be a statement and not an expression
- steveklabnik 6y agohttps://doc.rust-lang.org/stable/reference/expressions/return-expr.html#return-expressions https://doc.rust-lang.org/stable/reference/expressions/retur... They’re always expressions in Rust, though they are often written with ; to make an expression statement.
- chrismorgan 6y agoSee also https://doc.rust-lang.org/stable/reference/statements.html https://doc.rust-lang.org/stable/reference/statements.html on what statements are. Basically, the only thing that is a statement and can’t be an expression is `let pattern = expression;`.
- estebank 6y agoAnd even that will likely change in the future, letting you write things like if some_bool && let pat = expr {}