News for hackers. Stuff that matters.
Re:Rust Language Cheat Sheet by lifthrasiir on Monday August 05, 2019 @04:46AM (#20612419)
Every language item ends either with blocks (when a nested structure is required) or `;` (when it's not). They do not mix; if an item uses a block you don't need `;`.

So `type` needs no more blocks and ends with `;`, while `struct S { ... }` doesn't need `;`. Completing an example, there is another form of `struct` that looks like `struct S(u32);` which do need `;` by the aforementioned logic.

(The same logic applies to statements. You may think of an apparent exception like `{ println!("42"); 54 }`, but here `54` is an expression and you can't put a non-expression statement like `let x = 42` there without a semicolon.)

There are no comments on this comment yet.