diff options
| author | Brian Anderson <banderson@mozilla.com> | 2012-05-26 00:32:08 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2012-05-26 02:28:00 -0700 |
| commit | 432c6cbde93ca525cc33fd17873a0557dffa07c5 (patch) | |
| tree | f3b887343ed4473be3cfc7782bd3715175e316c3 /src/libcore/uint-template.rs | |
| parent | 5281db2bc273f089a872175f935c01f33dfa4326 (diff) | |
core: Make range follow the for loop protocol
Diffstat (limited to 'src/libcore/uint-template.rs')
| -rw-r--r-- | src/libcore/uint-template.rs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/libcore/uint-template.rs b/src/libcore/uint-template.rs index f9bffe3cc0f..e34fb145336 100644 --- a/src/libcore/uint-template.rs +++ b/src/libcore/uint-template.rs @@ -35,9 +35,12 @@ pure fn is_nonpositive(x: T) -> bool { x <= 0 as T } pure fn is_nonnegative(x: T) -> bool { x >= 0 as T } #[doc = "Iterate over the range [`lo`..`hi`)"] -fn range(lo: T, hi: T, it: fn(T)) { +fn range(lo: T, hi: T, it: fn(T) -> bool) { let mut i = lo; - while i < hi { it(i); i += 1 as T; } + while i < hi { + if !it(i) { break } + i += 1 as T; + } } #[doc = "Computes the bitwise complement"] |
