Skip to content

Commit 87cf286

Browse files
committed
rm obsolete documentation on for
it is documented in the container/iterator tutorial, not the basic tutorial
1 parent b41d047 commit 87cf286

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

doc/tutorial.md

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -567,11 +567,6 @@ loop {
567567
This code prints out a weird sequence of numbers and stops as soon as
568568
it finds one that can be divided by five.
569569

570-
Rust also has a `for` construct. It's different from C's `for` and it works
571-
best when iterating over collections. See the section on [closures](#closures)
572-
to find out how to use `for` and higher-order functions for enumerating
573-
elements of a collection.
574-
575570
# Data structures
576571

577572
## Structs
@@ -1397,8 +1392,8 @@ assert!(crayons.len() == 3);
13971392
assert!(!crayons.is_empty());
13981393
13991394
// Iterate over a vector, obtaining a pointer to each element
1400-
// (`for` is explained in the next section)
1401-
foreach crayon in crayons.iter() {
1395+
// (`for` is explained in the container/iterator tutorial)
1396+
for crayon in crayons.iter() {
14021397
let delicious_crayon_wax = unwrap_crayon(*crayon);
14031398
eat_crayon_wax(delicious_crayon_wax);
14041399
}
@@ -1749,7 +1744,7 @@ of `vector`:
17491744
~~~~
17501745
fn map<T, U>(vector: &[T], function: &fn(v: &T) -> U) -> ~[U] {
17511746
let mut accumulator = ~[];
1752-
foreach element in vector.iter() {
1747+
for element in vector.iter() {
17531748
accumulator.push(function(element));
17541749
}
17551750
return accumulator;
@@ -2027,7 +2022,7 @@ generic types.
20272022
~~~~
20282023
# trait Printable { fn print(&self); }
20292024
fn print_all<T: Printable>(printable_things: ~[T]) {
2030-
foreach thing in printable_things.iter() {
2025+
for thing in printable_things.iter() {
20312026
thing.print();
20322027
}
20332028
}
@@ -2073,7 +2068,7 @@ However, consider this function:
20732068
trait Drawable { fn draw(&self); }
20742069
20752070
fn draw_all<T: Drawable>(shapes: ~[T]) {
2076-
foreach shape in shapes.iter() { shape.draw(); }
2071+
for shape in shapes.iter() { shape.draw(); }
20772072
}
20782073
# let c: Circle = new_circle();
20792074
# draw_all(~[c]);
@@ -2088,7 +2083,7 @@ an _object_.
20882083
~~~~
20892084
# trait Drawable { fn draw(&self); }
20902085
fn draw_all(shapes: &[@Drawable]) {
2091-
foreach shape in shapes.iter() { shape.draw(); }
2086+
for shape in shapes.iter() { shape.draw(); }
20922087
}
20932088
~~~~
20942089

0 commit comments

Comments
 (0)