Skip to content

Commit ea32d01

Browse files
committed
auto merge of #8682 : adridu59/rust/master, r=cmr
2 parents db55cd9 + 892e8b8 commit ea32d01

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

doc/tutorial-container.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,18 @@ assert_eq!(sum, 57);
160160
161161
## For loops
162162
163+
The function `range` (or `range_inclusive`) allows to simply iterate through a given range:
164+
165+
~~~
166+
for i in range(0, 5) {
167+
printf!("%d ", i) // prints "0 1 2 3 4"
168+
}
169+
170+
for i in std::iterator::range_inclusive(0, 5) { // needs explicit import
171+
printf!("%d ", i) // prints "0 1 2 3 4 5"
172+
}
173+
~~~
174+
163175
The `for` keyword can be used as sugar for iterating through any iterator:
164176
165177
~~~

0 commit comments

Comments
 (0)