diff options
| author | bors <bors@rust-lang.org> | 2013-08-01 12:52:29 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-08-01 12:52:29 -0700 |
| commit | 82b24559e6aa0914f8a49e0a9dbfb3cf35372515 (patch) | |
| tree | c2b0ff9b26400eac3f3405d78fe89dc07607c3ae /src/libstd/num | |
| parent | 479809a267dbbcc3e2ec87da677c63430d3d229a (diff) | |
| parent | 94f1a5d6f8ecd30c6f59dfeaacdd5962f58bc44c (diff) | |
| download | rust-82b24559e6aa0914f8a49e0a9dbfb3cf35372515.tar.gz rust-82b24559e6aa0914f8a49e0a9dbfb3cf35372515.zip | |
auto merge of #8190 : thestinger/rust/for, r=thestinger
Diffstat (limited to 'src/libstd/num')
| -rw-r--r-- | src/libstd/num/uint.rs | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/libstd/num/uint.rs b/src/libstd/num/uint.rs index 126150c0f1b..275a72d6ecc 100644 --- a/src/libstd/num/uint.rs +++ b/src/libstd/num/uint.rs @@ -97,22 +97,21 @@ pub fn iterate(lo: uint, hi: uint, it: &fn(uint) -> bool) -> bool { impl iter::Times for uint { #[inline] /// - /// A convenience form for basic iteration. Given a uint `x`, - /// `for x.times { ... }` executes the given block x times. + /// A convenience form for basic repetition. Given a uint `x`, + /// `do x.times { ... }` executes the given block x times. /// /// Equivalent to `for uint::range(0, x) |_| { ... }`. /// /// Not defined on all integer types to permit unambiguous /// use with integer literals of inferred integer-type as - /// the self-value (eg. `for 100.times { ... }`). + /// the self-value (eg. `do 100.times { ... }`). /// - fn times(&self, it: &fn() -> bool) -> bool { + fn times(&self, it: &fn()) { let mut i = *self; while i > 0 { - if !it() { return false; } + it(); i -= 1; } - return true; } } @@ -190,6 +189,6 @@ pub fn test_times() { use iter::Times; let ten = 10 as uint; let mut accum = 0; - for ten.times { accum += 1; } + do ten.times { accum += 1; } assert!((accum == 10)); } |
