@@ -308,46 +308,6 @@ fn is_four(x: int) -> bool {
308308}
309309~~~~
310310
311- If all those things are expressions, you might conclude that you have
312- to add a terminating semicolon after * every* statement, even ones that
313- are not traditionally terminated with a semicolon in C (like ` while ` ).
314- That is not the case, though. Expressions that end in a block only
315- need a semicolon if that block contains a trailing expression. ` while `
316- loops do not allow trailing expressions, and ` if ` statements tend to
317- only have a trailing expression when you want to use their value for
318- something—in which case you'll have embedded it in a bigger statement.
319-
320- ~~~
321- # fn foo() -> bool { true }
322- # fn bar() -> bool { true }
323- # fn baz() -> bool { true }
324- // `let` is not an expression, so it is semicolon-terminated;
325- let x = foo();
326-
327- // When used in statement position, bracy expressions do not
328- // usually need to be semicolon terminated
329- if x {
330- bar();
331- } else {
332- baz();
333- } // No semi-colon
334-
335- // Although, if `bar` and `baz` have non-nil return types, and
336- // we try to use them as the tail expressions, rustc will
337- // make us terminate the expression.
338- if x {
339- bar()
340- } else {
341- baz()
342- }; // Semi-colon to ignore non-nil block type
343-
344- // An `if` embedded in `let` again requires a semicolon to terminate
345- // the `let` statement
346- let y = if x { foo() } else { bar() };
347- ~~~
348-
349- This may sound intricate, but it is super-useful and will grow on you.
350-
351311## Types
352312
353313The basic types include the usual boolean, integral, and floating-point types.
0 commit comments