Skip to content

Update documentation to use paren-free syntax #1044

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
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
32 changes: 16 additions & 16 deletions doc/rust.texi
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,7 @@ x::y::z;
@end example

In most contexts, the Rust grammar accepts a general @emph{path}, but
subsequent passes pay restrict paths occurring in various contexts to refer to
subsequent passes may restrict paths occurring in various contexts to refer to
slots or items, depending on the semantics of the occurrence. In other words:
in some contexts a slot is required (for example, on the left hand side of the
copy operator, @pxref{Ref.Expr.Copy}) and in other contexts an item is
Expand Down Expand Up @@ -1878,7 +1878,7 @@ were declared without the @code{!} annotation, the following code would not
typecheck:
@example
fn f(i: int) -> int @{
if (i == 42) @{
if i == 42 @{
ret 42;
@}
else @{
Expand Down Expand Up @@ -2008,7 +2008,7 @@ iter range(lo: int, hi: int) -> int @{
@}

let sum: int = 0;
for each (x: int in range(0,100)) @{
for each x: int in range(0,100) @{
sum += x;
@}
@end example
Expand Down Expand Up @@ -2464,7 +2464,7 @@ iter range(x: int, y: int) -> int @{
@}
@}

for each (i: int in range(5,7)) @{
for each i: int in range(5,7) @{
@dots{};
@}
@end example
Expand Down Expand Up @@ -3056,7 +3056,7 @@ and transfers control to the caller frame.
An example of a @code{ret} expression:
@example
fn max(a: int, b: int) -> int @{
if (a > b) @{
if a > b @{
ret a;
@}
ret b;
Expand All @@ -3081,7 +3081,7 @@ last expression in a block.
An example of a @code{be} expression:
@example
fn print_loop(n: int) @{
if (n <= 0) @{
if n <= 0 @{
ret;
@} else @{
print_int(n);
Expand Down Expand Up @@ -3172,7 +3172,7 @@ fn read_file_lines(path: str) -> [str] @{
note path;
let r: [str];
let f: file = open_read(path);
for each (s: str in lines(f)) @{
for each s: str in lines(f) @{
vec::append(r,s);
@}
ret r;
Expand Down Expand Up @@ -3271,7 +3271,7 @@ Example a for loop:
@example
let v: [foo] = [a, b, c];

for (foo e in v) @{
for e: foo in v @{
bar(e);
@}
@end example
Expand All @@ -3291,7 +3291,7 @@ Example of a foreach loop:
@example
let txt: str;
let lines: [str];
for each (s: str in str::split(txt, "\n")) @{
for each s: str in str::split(txt, "\n") @{
vec::push(lines, s);
@}
@end example
Expand All @@ -3304,9 +3304,9 @@ for each (s: str in str::split(txt, "\n")) @{
@cindex Control-flow

An @code{if} expression is a conditional branch in program control. The form of
an @code{if} expression is a parenthesized condition expression, followed by a
consequent block, any number of @code{else if} conditions and blocks, and an
optional trailing @code{else} block. The condition expressions must have type
an @code{if} expression is a condition expression, followed by a consequent
block, any number of @code{else if} conditions and blocks, and an optional
trailing @code{else} block. The condition expressions must have type
@code{bool}. If a condition expression evaluates to @code{true}, the
consequent block is executed and any subsequent @code{else if} or @code{else}
block is skipped. If a condition expression evaluates to @code{false}, the
Expand Down Expand Up @@ -3347,9 +3347,9 @@ expression following the @code{alt} when the case block completes.
A pattern @code{alt} expression branches on a @emph{pattern}. The exact form of
matching that occurs depends on the pattern. Patterns consist of some
combination of literals, tag constructors, variable binding specifications and
placeholders (@code{_}). A pattern @code{alt} has a parenthesized @emph{head
expression}, which is the value to compare to the patterns. The type of the
patterns must equal the type of the head expression.
placeholders (@code{_}). A pattern @code{alt} has a @emph{head expression},
which is the value to compare to the patterns. The type of the patterns must
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
Expand All @@ -3365,7 +3365,7 @@ type list<X> = tag(nil, cons(X, @@list<X>));

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

alt (x) @{
alt x @{
case (cons(a, cons(b, _))) @{
process_pair(a,b);
@}
Expand Down