Skip to content

Commit 225fd88

Browse files
committed
---
yaml --- r: 41502 b: refs/heads/master c: 7af1080 h: refs/heads/master v: v3
1 parent 661eace commit 225fd88

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 2d7b96ab72656c3f3e5a2d9b05ddcddbd1b2b2dd
2+
refs/heads/master: 7af1080f5ec466d94e2c4145a7df3732a3cf03e5
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 2f46b763da2c098913884f101b6d71d69af41b49
55
refs/heads/try: 3d5418789064fdb463e872a4e651af1c628a3650

trunk/src/libcore/vec.rs

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,9 +1177,41 @@ pub pure fn reversed<T: Copy>(v: &[const T]) -> ~[T] {
11771177
}
11781178

11791179
/**
1180-
* Iterates over a vector, with option to break
1180+
* Iterates over a vector, yielding each element to a closure.
11811181
*
1182-
* Return true to continue, false to break.
1182+
* # Arguments
1183+
*
1184+
* * `v` - A vector, to be iterated over
1185+
* * `f` - A closure to do the iterating. Within this closure, return true to continue iterating, false to break.
1186+
*
1187+
* # Examples
1188+
* ~~~
1189+
* [1,2,3].each(|&i| {
1190+
* io::println(int::str(i));
1191+
* true
1192+
* });
1193+
* ~~~
1194+
*
1195+
* ~~~
1196+
* [1,2,3,4,5].each(|&i| {
1197+
* if i < 4 {
1198+
* io::println(int::str(i));
1199+
* true
1200+
* }
1201+
* else {
1202+
* false
1203+
* }
1204+
* });
1205+
* ~~~
1206+
*
1207+
* You probably will want to use each with a `for`/`do` expression, depending
1208+
* on your iteration needs:
1209+
*
1210+
* ~~~
1211+
* for [1,2,3].each |&i| {
1212+
* io::println(int::str(i));
1213+
* }
1214+
* ~~~
11831215
*/
11841216
#[inline(always)]
11851217
pub pure fn each<T>(v: &r/[T], f: fn(&r/T) -> bool) {

0 commit comments

Comments
 (0)