about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAdrien Tétar <adri-from-59@hotmail.fr>2013-08-22 15:23:23 +0200
committeradridu59 <adri-from-59@hotmail.fr>2013-08-22 15:30:04 +0200
commit892e8b8ec1692a70d9e3a13ec6d8061d5b87a462 (patch)
treeb0005c2867894b0a0eb4f711877829b0a26fd7c5
parent3f6f79b789e8000ce4903857a210318e92724da8 (diff)
downloadrust-892e8b8ec1692a70d9e3a13ec6d8061d5b87a462.tar.gz
rust-892e8b8ec1692a70d9e3a13ec6d8061d5b87a462.zip
doc: add range iterators in the for loop section
-rw-r--r--doc/tutorial-container.md12
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:
 
 ~~~