Skip to content

Commit d5415a3

Browse files
committed
Remove iter and 'for each' from the documentation
1 parent 6864070 commit d5415a3

File tree

1 file changed

+7
-97
lines changed

1 file changed

+7
-97
lines changed

doc/rust.texi

Lines changed: 7 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -656,16 +656,16 @@ The keywords are:
656656
@tab @code{str}
657657
@tab @code{with}
658658
@tab @code{fn}
659-
@item @code{iter}
660-
@tab @code{pure}
659+
@item @code{pure}
661660
@tab @code{obj}
662661
@tab @code{resource}
663662
@tab @code{if}
664-
@item @code{else}
665-
@tab @code{alt}
663+
@tab @code{else}
664+
@item @code{alt}
666665
@tab @code{in}
667666
@tab @code{do}
668667
@tab @code{while}
668+
@tab @code{for}
669669
@item @code{break}
670670
@tab @code{cont}
671671
@tab @code{note}
@@ -674,10 +674,7 @@ The keywords are:
674674
@item @code{check}
675675
@tab @code{prove}
676676
@tab @code{fail}
677-
@tab @code{for}
678-
@tab @code{each}
679-
@item @code{ret}
680-
@tab @code{put}
677+
@tab @code{ret}
681678
@tab @code{be}
682679
@end multitable
683680

@@ -1688,7 +1685,6 @@ context. There are no general parametric types.
16881685
* Ref.Item.Mod:: Items defining modules.
16891686
* Ref.Item.Fn:: Items defining functions.
16901687
* Ref.Item.Pred:: Items defining predicates for typestates.
1691-
* Ref.Item.Iter:: Items defining iterators.
16921688
* Ref.Item.Obj:: Items defining objects.
16931689
* Ref.Item.Type:: Items defining the types of values and slots.
16941690
* Ref.Item.Tag:: Items defining the constructors of a tag type.
@@ -1970,48 +1966,6 @@ argument @code{f} is a pure function. So, to use @code{foldl} in a pure list
19701966
length function that a predicate could then use, we must use an
19711967
@code{unchecked} block wrapped around the call to @code{pure_foldl} in the
19721968
definition of @code{pure_length}.
1973-
1974-
@node Ref.Item.Iter
1975-
@subsection Ref.Item.Iter
1976-
@c * Ref.Item.Iter:: Items defining iterators.
1977-
1978-
@cindex Iterators
1979-
@cindex Put expression
1980-
@cindex Put each expression
1981-
@cindex Foreach expression
1982-
1983-
Iterators are function-like items that can @code{put} multiple values during
1984-
their execution before returning.
1985-
1986-
Putting a value is similar to returning a value -- the argument to @code{put}
1987-
is copied into the caller's frame and control transfers back to the caller --
1988-
but the iterator frame is only @emph{suspended} during the put, and will be
1989-
@emph{resumed} at the point after the @code{put}, on the next iteration of
1990-
the caller's loop.
1991-
1992-
The output type of an iterator is the type of value that the function will
1993-
@code{put}, before it eventually evaluates a @code{ret} or @code{be} expression
1994-
of type @code{()} and completes its execution.
1995-
1996-
An iterator can be called only in the loop header of a matching @code{for
1997-
each} loop or as the argument in a @code{put each} expression.
1998-
@xref{Ref.Expr.Foreach}.
1999-
2000-
An example of an iterator:
2001-
@example
2002-
iter range(lo: int, hi: int) -> int @{
2003-
let i: int = lo;
2004-
while (i < hi) @{
2005-
put i;
2006-
i = i + 1;
2007-
@}
2008-
@}
2009-
2010-
let sum: int = 0;
2011-
for each x: int in range(0,100) @{
2012-
sum += x;
2013-
@}
2014-
@end example
20151969

20161970

20171971
@node Ref.Item.Obj
@@ -2165,7 +2119,6 @@ Rust; they cannot be used as user-defined identifiers in any context.
21652119
* Ref.Type.Vec:: Open products of homogeneous types.
21662120
* Ref.Type.Tag:: Disjoint unions of heterogeneous types.
21672121
* Ref.Type.Fn:: Subroutine types.
2168-
* Ref.Type.Iter:: Scoped coroutine types.
21692122
* Ref.Type.Obj:: Abstract types.
21702123
* Ref.Type.Constr:: Constrained types.
21712124
* Ref.Type.Type:: Types describing types.
@@ -2447,28 +2400,6 @@ let bo: binop = add;
24472400
x = bo(5,7);
24482401
@end example
24492402

2450-
@node Ref.Type.Iter
2451-
@subsection Ref.Type.Iter
2452-
@cindex Iterator types
2453-
2454-
The iterator type-constructor @code{iter} forms new iterator types. An
2455-
iterator type consists a sequence of input slots, an optional set of input
2456-
constraints and an output slot. @xref{Ref.Item.Iter}.
2457-
2458-
An example of an @code{iter} type:
2459-
@example
2460-
iter range(x: int, y: int) -> int @{
2461-
while (x < y) @{
2462-
put x;
2463-
x += 1;
2464-
@}
2465-
@}
2466-
2467-
for each i: int in range(5,7) @{
2468-
@dots{};
2469-
@}
2470-
@end example
2471-
24722403
@node Ref.Type.Obj
24732404
@subsection Ref.Type.Obj
24742405
@c * Ref.Type.Obj:: Object types.
@@ -2938,7 +2869,6 @@ effects of the expression's evaluation.
29382869
* Ref.Expr.Break:: Expression for terminating a loop.
29392870
* Ref.Expr.Cont:: Expression for terminating a single loop iteration.
29402871
* Ref.Expr.For:: Expression for looping over strings and vectors.
2941-
* Ref.Expr.Foreach:: Expression for looping via an iterator.
29422872
* Ref.Expr.If:: Expression for simple conditional branching.
29432873
* Ref.Expr.Alt:: Expression for complex conditional branching.
29442874
* Ref.Expr.Prove:: Expression for static assertion of typestate.
@@ -3197,8 +3127,8 @@ fn read_file_lines(path: str) -> [str] @{
31973127
note path;
31983128
let r: [str];
31993129
let f: file = open_read(path);
3200-
for each s: str in lines(f) @{
3201-
vec::append(r,s);
3130+
lines(f) @{|s|
3131+
r += [s];
32023132
@}
32033133
ret r;
32043134
@}
@@ -3301,26 +3231,6 @@ for e: foo in v @{
33013231
@}
33023232
@end example
33033233

3304-
@node Ref.Expr.Foreach
3305-
@subsection Ref.Expr.Foreach
3306-
@c * Ref.Expr.Foreach:: Expression for general conditional looping.
3307-
@cindex Foreach expression
3308-
@cindex Loops
3309-
@cindex Control-flow
3310-
3311-
An @dfn{foreach loop} is denoted by the @code{for each} keywords, and is
3312-
controlled by an iterator. The loop executes once for each value @code{put} by
3313-
the iterator. When the iterator returns or fails, the loop terminates.
3314-
3315-
Example of a foreach loop:
3316-
@example
3317-
let txt: str;
3318-
let lines: [str];
3319-
for each s: str in str::split(txt, "\n") @{
3320-
vec::push(lines, s);
3321-
@}
3322-
@end example
3323-
33243234

33253235
@node Ref.Expr.If
33263236
@subsection Ref.Expr.If

0 commit comments

Comments
 (0)