4 ms·
Block expression https://doc.rust-lang.org/reference/expressions/block-expr.html https://doc.rust-lang.org/reference/expressions/block-expr.h... Also in Kotlin
by esafak 11mo ago
Block expression https://doc.rust-lang.org/reference/expressions/block-expr.html https://doc.rust-lang.org/reference/expressions/block-expr.h...
Also in Kotlin, Scala, and nim.
- IshKebab 11mo agoI think this comes from functional programming. I'd just call it "everything is an expression" (which isn't quite true in Rust but it's a lot more true than it is in traditional imperative languages like C++ and Python).
- afdbcreid 11mo agoThe only things in Rust that are real statements are `let` statements, and item statements (e.g. declaring an `fn` inside a function). All other statements are in fact expressions, although some always return `()` so they're not really useful as such.
- IshKebab 11mo agoSurely declaring structs, traits, top-level functions, etc?