As discussed, I have pushed the changes which allow block syntactic sugar in expressions. I think the best way to describe the rules is as follows:

- In Rust, a statement is either a declaration or an expression followed by a semicolon. The result of evaluating the expression is ignored.

- For certain expressions, however, the semicolon may be omitted. In that case, the result type of the expression must be unit. These expressions are (a) C-like special forms that begin with `if`, `while`, `do`, or `alt`; (b) standalone blocks `{...}`; (c) sugared calls with block arguments `expr {|| ...)`.

- The value of a block expression `{a; b; c}` is the value of the final expression in the block (`c`, in this case). If a block consists of only statements (e.g., `{a; b;}`) then the value of the block is unit.

When phrased this way, I think the rules seem simple enough (but then I would, wouldn't I?). So yes, let's see how it goes: if it seems to trip people up or feels too complex, I'm happy to reverse the changes and give up.


Niko
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to