News for hackers. Stuff that matters.
Re:Notes on a Smaller Rust by skohan on Thursday July 18, 2019 @10:42AM (#20470309)
It's a bit of a semantic distinction isn't it? In practice what it means is that you add semicolons to the end of almost every line of imperative code in a block, and you leave the semicolon off the last line and this becomes your return value implicitly (without the use of a return keyword).
Re:Notes on a Smaller Rust by steveklabnik on Thursday July 18, 2019 @10:48AM (#20470383)
It is a semantic distinction, because "everything is an expression" and "implicit returns" have different semantics.

Thinking of them as implicit returns leads people to believe they can write code like

  fn foo(x: bool) -> i32 {
      if x {
          5
      }

      // more code
and then they're confused when this doesn't work.