@@ -600,6 +600,11 @@ within this loop may exit out of this loop or return control to its head.
600
600
See [ break expressions] ( #break-expressions ) and [ continue
601
601
expressions] ( #continue-expressions ) .
602
602
603
+ A ` loop ` expression is [ diverging] ( items.html#diverging-functions ) , and doesn't
604
+ return anything. However, when it contains a [ break
605
+ expression] ( #break-expressions ) , it returns the value attached to the ` break `
606
+ that caused the loop to stop.
607
+
603
608
## ` break ` expressions
604
609
605
610
A ` break ` expression has an optional _ label_ . If the label is absent, then
@@ -608,6 +613,14 @@ enclosing it. It is only permitted in the body of a loop. If the label is
608
613
present, then ` break 'foo ` terminates the loop with label ` 'foo ` , which need not
609
614
be the innermost label enclosing the ` break ` expression, but must enclose it.
610
615
616
+ When the ` break ` expression is enclosed in a ` loop ` it has an optional return
617
+ value attached which will be returned by the loop ended by the
618
+ expression. When it's not provided it defaults to ` () ` .
619
+
620
+ If both a label and a return value are present in the expression, the label
621
+ must be placed before the return value. For example ` break 'label 42 ` breaks
622
+ the loop labelled ` 'label ` , returning ` 42 ` from it.
623
+
611
624
## ` continue ` expressions
612
625
613
626
A ` continue ` expression has an optional _ label_ . If the label is absent, then
0 commit comments