]> git.lizzy.rs Git - rust.git/commitdiff
Add `while let` to the reference
authorJohn Gallagher <jgallagher@bignerdranch.com>
Fri, 3 Oct 2014 05:09:01 +0000 (01:09 -0400)
committerJohn Gallagher <jgallagher@bignerdranch.com>
Sat, 11 Oct 2014 00:30:32 +0000 (20:30 -0400)
Closes #17687

src/doc/reference.md

index 261e5edcf665ba00c85189f48a09e2abc14c1c3e..4ad64576e1588a01e7e53ef96bf9532407a901ae 100644 (file)
@@ -3511,6 +3511,18 @@ of a condition expression it expects a refutable let statement. If the value of
 expression on the right hand side of the let statement matches the pattern, the corresponding
 block will execute, otherwise flow proceeds to the first `else` block that follows.
 
+### While let loops
+
+```{.ebnf .gram}
+while_let_expr : "while" "let" pat '=' expr '{' block '}' ;
+```
+
+A `while let` loop is semantically identical to a `while` loop but in place of a
+condition expression it expects a refutable let statement. If the value of the
+expression on the right hand side of the let statement matches the pattern, the
+loop body block executes and control returns to the pattern matching statement.
+Otherwise, the while expression completes.
+
 ### Return expressions
 
 ```{.ebnf .gram}