Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions doc/rust.texi
Original file line number Diff line number Diff line change
Expand Up @@ -2133,7 +2133,7 @@ tag list<T> @{
cons(T, @@list<T>);
@}

let a: list<int> = cons(7, cons(13, nil));
let a: list<int> = cons(7, @@cons(13, @@nil));
@end example


Expand Down Expand Up @@ -3353,26 +3353,25 @@ equal the type of the head expression.

To execute a pattern @code{alt} expression, first the head expression is
evaluated, then its value is sequentially compared to the patterns in the arms
until a match is found. The first arm with a matching @code{case} pattern is
chosen as the branch target of the @code{alt}, any variables bound by the
pattern are assigned to local slots in the arm's block, and control enters the
block.
until a match is found. The first arm with a matching pattern is chosen as the
branch target of the @code{alt}, any variables bound by the pattern are
assigned to local slots in the arm's block, and control enters the block.

An example of a pattern @code{alt} expression:

@example
type list<X> = tag(nil, cons(X, @@list<X>));
tag list<X> @{ nil; cons(X, @@list<X>); @}

let x: list<int> = cons(10, cons(11, nil));
let x: list<int> = cons(10, @@cons(11, @@nil));

alt x @{
case (cons(a, cons(b, _))) @{
cons(a, @@cons(b, _)) @{
process_pair(a,b);
@}
case (cons(v=10, _)) @{
process_ten(v);
cons(10, _) @{
process_ten();
@}
case (_) @{
_ @{
fail;
@}
@}
Expand Down