From 87cf2864b1e427753f3153ee31aafcff19e253ca Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Sat, 3 Aug 2013 01:33:06 -0400 Subject: [PATCH] rm obsolete documentation on `for` it is documented in the container/iterator tutorial, not the basic tutorial --- doc/tutorial.md | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/doc/tutorial.md b/doc/tutorial.md index 89c3fa0bcaec..a5f2001eaf51 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -567,11 +567,6 @@ loop { This code prints out a weird sequence of numbers and stops as soon as it finds one that can be divided by five. -Rust also has a `for` construct. It's different from C's `for` and it works -best when iterating over collections. See the section on [closures](#closures) -to find out how to use `for` and higher-order functions for enumerating -elements of a collection. - # Data structures ## Structs @@ -1397,8 +1392,8 @@ assert!(crayons.len() == 3); assert!(!crayons.is_empty()); // Iterate over a vector, obtaining a pointer to each element -// (`for` is explained in the next section) -foreach crayon in crayons.iter() { +// (`for` is explained in the container/iterator tutorial) +for crayon in crayons.iter() { let delicious_crayon_wax = unwrap_crayon(*crayon); eat_crayon_wax(delicious_crayon_wax); } @@ -1749,7 +1744,7 @@ of `vector`: ~~~~ fn map(vector: &[T], function: &fn(v: &T) -> U) -> ~[U] { let mut accumulator = ~[]; - foreach element in vector.iter() { + for element in vector.iter() { accumulator.push(function(element)); } return accumulator; @@ -2027,7 +2022,7 @@ generic types. ~~~~ # trait Printable { fn print(&self); } fn print_all(printable_things: ~[T]) { - foreach thing in printable_things.iter() { + for thing in printable_things.iter() { thing.print(); } } @@ -2073,7 +2068,7 @@ However, consider this function: trait Drawable { fn draw(&self); } fn draw_all(shapes: ~[T]) { - foreach shape in shapes.iter() { shape.draw(); } + for shape in shapes.iter() { shape.draw(); } } # let c: Circle = new_circle(); # draw_all(~[c]); @@ -2088,7 +2083,7 @@ an _object_. ~~~~ # trait Drawable { fn draw(&self); } fn draw_all(shapes: &[@Drawable]) { - foreach shape in shapes.iter() { shape.draw(); } + for shape in shapes.iter() { shape.draw(); } } ~~~~