2 ms·
I agree that because of common uses of things like match in Rust it makes it consistent to also do it for functions. I don't agree that the reason why it's cons
by cyphar 8y ago
I agree that because of common uses of things like match in Rust it makes it consistent to also do it for functions. I don't agree that the reason why it's consistent is because a function body is an expression (though of course you have more expertise than me on this one -- and Rust does actually treat scopes much more strictly than most other languages so you could argue every scope has the smell of a function call associated with it).
- steveklabnik 8y agoHere's the citation: https://doc.rust-lang.org/reference/items/functions.html https://doc.rust-lang.org/reference/items/functions.html > A function consists of a block, along with a name and a set of parameters. https://doc.rust-lang.org/reference/expressions/block-expr.html https://doc.rust-lang.org/reference/expressions/block-expr.h... > Blocks are always value expressions and evaluate the last expression in value expression context.