diff options
| author | bors <bors@rust-lang.org> | 2013-08-23 02:46:24 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-08-23 02:46:24 -0700 |
| commit | ea32d019c4f8da8a1754e9c69a1ba98832c8889c (patch) | |
| tree | 891ab11cd5629153d837226893e0a4a705bd2254 | |
| parent | db55cd92dec88c3ff025ecf8b4900aca4520bea6 (diff) | |
| parent | 892e8b8ec1692a70d9e3a13ec6d8061d5b87a462 (diff) | |
| download | rust-ea32d019c4f8da8a1754e9c69a1ba98832c8889c.tar.gz rust-ea32d019c4f8da8a1754e9c69a1ba98832c8889c.zip | |
auto merge of #8682 : adridu59/rust/master, r=cmr
| -rw-r--r-- | doc/tutorial-container.md | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/doc/tutorial-container.md b/doc/tutorial-container.md index 37ca561f74a..f2c3d8d4450 100644 --- a/doc/tutorial-container.md +++ b/doc/tutorial-container.md @@ -160,6 +160,18 @@ assert_eq!(sum, 57); ## For loops +The function `range` (or `range_inclusive`) allows to simply iterate through a given range: + +~~~ +for i in range(0, 5) { + printf!("%d ", i) // prints "0 1 2 3 4" +} + +for i in std::iterator::range_inclusive(0, 5) { // needs explicit import + printf!("%d ", i) // prints "0 1 2 3 4 5" +} +~~~ + The `for` keyword can be used as sugar for iterating through any iterator: ~~~ |
