Format for Statements
This lesson discusses how to write any statement.
let
Statements
There should be spaces after the : and on both sides of the = (if they are present). No space before the semi-colon.
// A comment.
let pattern: Type = expr;
let pattern;
let pattern: Type;
let pattern = expr;
Macros in Statement Position
- A macro use in statement position should use parentheses or square brackets as delimiters and should be terminated with a semi-colon.
- There should be no spaces between the name, !, the delimiters, the delimiters, or the ;.
// A comment.
a_macro!(...);
Expressions in Statement Position
- There should be no space between the expression and the semi-colon.
<expr>;
- All expressions in statement position should be terminated with a semi-colon, unless they end with a block or are used as the value for a block.
{
an_expression();
expr_as_value()
}