Skip to content

Commit c9ddca7

Browse files
committed
Document let else statements
1 parent 411c2f0 commit c9ddca7

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/statements.md

+22
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
>       `;`\
66
>    | [_Item_]\
77
>    | [_LetStatement_]\
8+
>    | [_LetElseStatement_]\
89
>    | [_ExpressionStatement_]\
910
>    | [_MacroInvocationSemi_]
1011
@@ -65,6 +66,25 @@ inference. Any variables introduced by a variable declaration are visible
6566
from the point of declaration until the end of the enclosing block scope,
6667
except when they are shadowed by another variable declaration.
6768

69+
70+
### `let else` statements
71+
72+
> **<sup>Syntax</sup>**\
73+
> _LetElseStatement_ :\
74+
> &nbsp;&nbsp; [_OuterAttribute_]<sup>\*</sup> `let` [_PatternNoTopAlt_]
75+
> ( `:` [_Type_] )<sup>?</sup> `=` [_Expression_] `else` [_BlockExpression_] `;`
76+
77+
A *`let else` statement* introduces a new set of [variables], given by a
78+
refutable [pattern]. The pattern is followed optionally by a type
79+
annotation. When no type annotation is given, the compiler will infer the type,
80+
or signal an error if insufficient type information is available for definite
81+
inference. It is is then followed by an initializer expression as well as a
82+
diverging `else` block.
83+
84+
Any variables introduced by a variable declaration are visible
85+
from the point of declaration until the end of the enclosing block scope,
86+
except when they are shadowed by another variable declaration.
87+
6888
## Expression statements
6989

7090
> **<sup>Syntax</sup>**\
@@ -128,10 +148,12 @@ statement are [`cfg`], and [the lint check attributes].
128148
[`cfg`]: conditional-compilation.md
129149
[the lint check attributes]: attributes/diagnostics.md#lint-check-attributes
130150
[pattern]: patterns.md
151+
[_BlockExpression_]: expressions/block-expr.md
131152
[_ExpressionStatement_]: #expression-statements
132153
[_Expression_]: expressions.md
133154
[_Item_]: items.md
134155
[_LetStatement_]: #let-statements
156+
[_LetElseStatement_]: #let-else-statements
135157
[_MacroInvocationSemi_]: macros.md#macro-invocation
136158
[_OuterAttribute_]: attributes.md
137159
[_PatternNoTopAlt_]: patterns.md

0 commit comments

Comments
 (0)