Skip to content

Commit bacb7da

Browse files
committed
---
yaml --- r: 52050 b: refs/heads/dist-snap c: 7af1080 h: refs/heads/master v: v3
1 parent ec2a8c9 commit bacb7da

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
@@ -7,7 +7,7 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
99
refs/heads/incoming: 44d4d6de762f3f9aae1fedcf454c66b79b3ad58d
10-
refs/heads/dist-snap: 2d7b96ab72656c3f3e5a2d9b05ddcddbd1b2b2dd
10+
refs/heads/dist-snap: 7af1080f5ec466d94e2c4145a7df3732a3cf03e5
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1313
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/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)