Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

core: Make range follow the for loop protocol

  • Loading branch information...
commit 432c6cbde93ca525cc33fd17873a0557dffa07c5 1 parent 5281db2
@brson brson authored
Showing with 102 additions and 88 deletions.
  1. +1 −1  src/compiletest/runtest.rs
  2. +5 −2 src/libcore/int-template.rs
  3. +3 −3 src/libcore/priv.rs
  4. +1 −1  src/libcore/rand.rs
  5. +5 −2 src/libcore/uint-template.rs
  6. +1 −1  src/libcore/vec.rs
  7. +1 −1  src/librustsyntax/codemap.rs
  8. +1 −1  src/librustsyntax/ext/qquote.rs
  9. +5 −5 src/libstd/bitv.rs
  10. +6 −6 src/libstd/rope.rs
  11. +1 −1  src/rustc/back/rpath.rs
  12. +1 −1  src/rustc/metadata/encoder.rs
  13. +4 −4 src/rustc/middle/liveness.rs
  14. +1 −1  src/rustc/middle/trans/native.rs
  15. +1 −1  src/rustc/middle/trans/shape.rs
  16. +2 −2 src/rustc/middle/trans/type_use.rs
  17. +1 −1  src/test/auxiliary/cci_class_5.rs
  18. +2 −2 src/test/bench/core-vec-append.rs
  19. +2 −2 src/test/bench/msgsend.rs
  20. +2 −2 src/test/bench/shootout-fasta.rs
  21. +2 −2 src/test/bench/shootout-mandelbrot.rs
  22. +3 −3 src/test/bench/shootout-pfib.rs
  23. +1 −1  src/test/bench/shootout-threadring.rs
  24. +3 −3 src/test/bench/std-smallintmap.rs
  25. +8 −8 src/test/bench/sudoku.rs
  26. +2 −2 src/test/bench/task-perf-vector-party.rs
  27. +1 −1  src/test/compile-fail/borrowck-lend-flow.rs
  28. +1 −1  src/test/compile-fail/issue-1965.rs
  29. +1 −1  src/test/run-fail/unwind-misc-1.rs
  30. +1 −1  src/test/run-pass/class-cast-to-iface-multiple-types.rs
  31. +1 −1  src/test/run-pass/class-impl-parameterized-iface.rs
  32. +1 −1  src/test/run-pass/class-implement-iface-cross-crate.rs
  33. +1 −1  src/test/run-pass/class-implement-ifaces.rs
  34. +1 −1  src/test/run-pass/class-implements-multiple-ifaces.rs
  35. +1 −1  src/test/run-pass/classes-cross-crate.rs
  36. +1 −1  src/test/run-pass/classes.rs
  37. +9 −1 src/test/run-pass/issue-2185.rs
  38. +1 −1  src/test/run-pass/lots-a-fail.rs
  39. +1 −1  src/test/run-pass/move-3-unique.rs
  40. +1 −1  src/test/run-pass/move-3.rs
  41. +1 −1  src/test/run-pass/pattern-bound-var-in-for-each.rs
  42. +1 −1  src/test/run-pass/private-method.rs
  43. +7 −7 src/test/run-pass/rt-circular-buffer.rs
  44. +1 −1  src/test/run-pass/send-iloop.rs
  45. +3 −3 src/test/run-pass/task-comm-chan-cleanup4.rs
  46. +2 −2 src/test/run-pass/unique-send-2.rs
View
2  src/compiletest/runtest.rs
@@ -277,7 +277,7 @@ fn check_expected_errors(expected_errors: [errors::expected_error],
}
}
- uint::range(0u, vec::len(found_flags)) {|i|
+ for uint::range(0u, vec::len(found_flags)) {|i|
if !found_flags[i] {
let ee = expected_errors[i];
fatal_procres(#fmt["expected %s on line %u not found: %s",
View
7 src/libcore/int-template.rs
@@ -36,9 +36,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"]
View
6 src/libcore/priv.rs
@@ -127,12 +127,12 @@ fn test_from_global_chan2() unsafe {
// Spawn a bunch of tasks that all want to compete to
// create the global channel
- uint::range(0u, 10u) {|i|
+ for uint::range(0u, 10u) {|i|
task::spawn() {||
let ch = chan_from_global_ptr(
globchanp, task::builder) {|po|
- uint::range(0u, 10u) {|_j|
+ for uint::range(0u, 10u) {|_j|
let ch = comm::recv(po);
comm::send(ch, {i});
}
@@ -147,7 +147,7 @@ fn test_from_global_chan2() unsafe {
}
// There should be only one winner
let mut winners = 0u;
- uint::range(0u, 10u) {|_i|
+ for uint::range(0u, 10u) {|_i|
let res = comm::recv(resultpo);
if res { winners += 1u };
}
View
2  src/libcore/rand.rs
@@ -202,7 +202,7 @@ impl extensions for rng {
fn weighted_vec<T:copy>(v: [weighted<T>]) -> [T] {
let mut r = [];
for v.each {|item|
- uint::range(0u, item.weight) {|_i|
+ for uint::range(0u, item.weight) {|_i|
r += [item.item];
}
}
View
7 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"]
View
2  src/libcore/vec.rs
@@ -892,7 +892,7 @@ Both vectors must have the same length
#[inline]
fn iter2<U, T>(v1: [const U], v2: [const T], f: fn(U, T)) {
assert len(v1) == len(v2);
- uint::range(0u, len(v1)) {|i|
+ for uint::range(0u, len(v1)) {|i|
f(v1[i], v2[i])
}
}
View
2  src/librustsyntax/codemap.rs
@@ -183,7 +183,7 @@ fn span_to_lines(sp: span, cm: codemap::codemap) -> @file_lines {
let lo = lookup_char_pos(cm, sp.lo);
let hi = lookup_char_pos(cm, sp.hi);
let mut lines = [];
- uint::range(lo.line - 1u, hi.line as uint) {|i| lines += [i]; };
+ for uint::range(lo.line - 1u, hi.line as uint) {|i| lines += [i]; };
ret @{file: lo.file, lines: lines};
}
View
2  src/librustsyntax/ext/qquote.rs
@@ -193,7 +193,7 @@ fn finish<T: qq_helper>
let qcx = gather_anti_quotes(sp.lo, node);
let cx = qcx;
- uint::range(1u, cx.gather.len()) {|i|
+ for uint::range(1u, cx.gather.len()) {|i|
assert cx.gather[i-1u].lo < cx.gather[i].lo;
// ^^ check that the vector is sorted
assert cx.gather[i-1u].hi <= cx.gather[i].lo;
View
10 src/libstd/bitv.rs
@@ -46,7 +46,7 @@ fn process(v0: bitv, v1: bitv, op: fn(uint, uint) -> uint) -> bool {
assert (vec::len(v0.storage) == len);
assert (v0.nbits == v1.nbits);
let mut changed = false;
- uint::range(0u, len) {|i|
+ for uint::range(0u, len) {|i|
let w0 = v0.storage[i];
let w1 = v1.storage[i];
let w = op(w0, w1);
@@ -90,7 +90,7 @@ fn assign(v0: bitv, v1: bitv) -> bool {
fn clone(v: bitv) -> bitv {
let storage = vec::to_mut(vec::from_elem(v.nbits / uint_bits + 1u, 0u));
let len = vec::len(v.storage);
- uint::range(0u, len) {|i| storage[i] = v.storage[i]; };
+ for uint::range(0u, len) {|i| storage[i] = v.storage[i]; };
ret @{storage: storage, nbits: v.nbits};
}
@@ -121,17 +121,17 @@ fn equal(v0: bitv, v1: bitv) -> bool {
#[doc = "Set all bits to 0"]
fn clear(v: bitv) {
- uint::range(0u, vec::len(v.storage)) {|i| v.storage[i] = 0u; };
+ for uint::range(0u, vec::len(v.storage)) {|i| v.storage[i] = 0u; };
}
#[doc = "Set all bits to 1"]
fn set_all(v: bitv) {
- uint::range(0u, v.nbits) {|i| set(v, i, true); };
+ for uint::range(0u, v.nbits) {|i| set(v, i, true); };
}
#[doc = "Invert all bits"]
fn invert(v: bitv) {
- uint::range(0u, vec::len(v.storage)) {|i|
+ for uint::range(0u, vec::len(v.storage)) {|i|
v.storage[i] = !v.storage[i];
};
}
View
12 src/libstd/rope.rs
@@ -158,13 +158,13 @@ fn concat(v: [rope]) -> rope {
let mut len = vec::len(v);
if len == 0u { ret node::empty; }
let ropes = vec::to_mut(vec::from_elem(len, v[0]));
- uint::range(1u, len) {|i|
+ for uint::range(1u, len) {|i|
ropes[i] = v[i];
}
//Merge progresively
while len > 1u {
- uint::range(0u, len/2u) {|i|
+ for uint::range(0u, len/2u) {|i|
ropes[i] = append_rope(ropes[2u*i], ropes[2u*i+1u]);
}
if len%2u != 0u {
@@ -1352,19 +1352,19 @@ mod tests {
fn char_at1() {
//Generate a large rope
let mut r = of_str(@ "123456789");
- uint::range(0u, 10u){|_i|
+ for uint::range(0u, 10u){|_i|
r = append_rope(r, r);
}
//Copy it in the slowest possible way
let mut r2 = empty();
- uint::range(0u, char_len(r)){|i|
+ for uint::range(0u, char_len(r)){|i|
r2 = append_char(r2, char_at(r, i));
}
assert eq(r, r2);
let mut r3 = empty();
- uint::range(0u, char_len(r)){|i|
+ for uint::range(0u, char_len(r)){|i|
r3 = prepend_char(r3, char_at(r, char_len(r) - i - 1u));
}
assert eq(r, r3);
@@ -1385,7 +1385,7 @@ mod tests {
//Generate a reasonable rope
let chunk = of_str(@ "123456789");
let mut r = empty();
- uint::range(0u, 10u){|_i|
+ for uint::range(0u, 10u){|_i|
r = append_rope(r, chunk);
}
View
2  src/rustc/back/rpath.rs
@@ -137,7 +137,7 @@ fn get_relative_to(abs1: path::path, abs2: path::path) -> path::path {
}
let mut path = [];
- uint::range(start_idx, len1 - 1u) {|_i| path += [".."]; };
+ for uint::range(start_idx, len1 - 1u) {|_i| path += [".."]; };
path += vec::slice(split2, start_idx, len2 - 1u);
View
2  src/rustc/metadata/encoder.rs
@@ -840,7 +840,7 @@ fn encode_info_for_items(ecx: @encode_ctxt, ebml_w: ebml::writer,
fn create_index<T: copy>(index: [entry<T>], hash_fn: fn@(T) -> uint) ->
[@[entry<T>]] {
let mut buckets: [@mut [entry<T>]] = [];
- uint::range(0u, 256u) {|_i| buckets += [@mut []]; };
+ for uint::range(0u, 256u) {|_i| buckets += [@mut []]; };
for index.each {|elt|
let h = hash_fn(elt.val);
*buckets[h % 256u] += [elt];
View
8 src/rustc/middle/liveness.rs
@@ -595,7 +595,7 @@ class liveness {
fn indices(ln: live_node, op: fn(uint)) {
let node_base_idx = self.idx(ln, variable(0u));
- uint::range(0u, self.ir.num_vars) { |var_idx|
+ for uint::range(0u, self.ir.num_vars) { |var_idx|
op(node_base_idx + var_idx)
}
}
@@ -604,7 +604,7 @@ class liveness {
op: fn(uint, uint)) {
let node_base_idx = self.idx(ln, variable(0u));
let succ_base_idx = self.idx(succ_ln, variable(0u));
- uint::range(0u, self.ir.num_vars) { |var_idx|
+ for uint::range(0u, self.ir.num_vars) { |var_idx|
op(node_base_idx + var_idx, succ_base_idx + var_idx);
}
}
@@ -613,7 +613,7 @@ class liveness {
ln: live_node,
test: fn(uint) -> live_node) {
let node_base_idx = self.idx(ln, variable(0u));
- uint::range(0u, self.ir.num_vars) { |var_idx|
+ for uint::range(0u, self.ir.num_vars) { |var_idx|
let idx = node_base_idx + var_idx;
if test(idx).is_valid() {
wr.write_str(" ");
@@ -743,7 +743,7 @@ class liveness {
// hack to skip the loop unless #debug is enabled:
#debug["^^ liveness computation results for body %d (entry=%s)",
{
- uint::range(0u, self.ir.num_live_nodes) { |ln_idx|
+ for uint::range(0u, self.ir.num_live_nodes) { |ln_idx|
#debug["%s", self.ln_str(live_node(ln_idx))];
}
body.node.id
View
2  src/rustc/middle/trans/native.rs
@@ -945,7 +945,7 @@ fn trans_crust_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl,
_ {
let llretptr = alloca(bcx, tys.ret_ty);
let n = vec::len(tys.arg_tys);
- uint::range(0u, n) {|i|
+ for uint::range(0u, n) {|i|
let llargval = get_param(llwrapfn, i);
store_inbounds(bcx, llargval, llargbundle,
[0u, i]);
View
2  src/rustc/middle/trans/shape.rs
@@ -588,7 +588,7 @@ fn gen_enum_shapes(ccx: @crate_ctxt) -> ValueRef {
fn gen_resource_shapes(ccx: @crate_ctxt) -> ValueRef {
let mut dtors = [];
let len = interner::len(ccx.shape_cx.resources);
- uint::range(0u, len) {|i|
+ for uint::range(0u, len) {|i|
let ri = interner::get(ccx.shape_cx.resources, i);
dtors += [trans::base::get_res_dtor(ccx, ri.did, ri.tps)];
}
View
4 src/rustc/middle/trans/type_use.rs
@@ -73,7 +73,7 @@ fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint)
}
ast_map::node_ctor(_, _, ast_map::res_ctor(_, _, _), _) |
ast_map::node_variant(_, _, _) {
- uint::range(0u, n_tps) {|n| cx.uses[n] |= use_repr;}
+ for uint::range(0u, n_tps) {|n| cx.uses[n] |= use_repr;}
}
ast_map::node_native_item(i@@{node: native_item_fn(_, _), _}, abi, _) {
if abi == native_abi_rust_intrinsic {
@@ -84,7 +84,7 @@ fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint)
"get_tydesc" | "needs_drop" { use_tydesc }
"forget" | "addr_of" { 0u }
};
- uint::range(0u, n_tps) {|n| cx.uses[n] |= flags;}
+ for uint::range(0u, n_tps) {|n| cx.uses[n] |= flags;}
}
}
ast_map::node_ctor(_, _, ast_map::class_ctor(ctor, _), _){
View
2  src/test/auxiliary/cci_class_5.rs
@@ -3,7 +3,7 @@ mod kitties {
class cat {
priv {
let mut meows : uint;
- fn nap() { uint::range(1u, 10000u) {|_i|}}
+ fn nap() { for uint::range(1u, 10000u) {|_i|}}
}
let how_hungry : int;
View
4 src/test/bench/core-vec-append.rs
@@ -6,7 +6,7 @@ import io::writer_util;
fn collect_raw(num: uint) -> [uint] {
let mut result = [];
- uint::range(0u, num) { |i|
+ for uint::range(0u, num) { |i|
result += [i];
}
ret result;
@@ -14,7 +14,7 @@ fn collect_raw(num: uint) -> [uint] {
fn collect_dvec(num: uint) -> [mut uint] {
let result = dvec();
- uint::range(0u, num) { |i|
+ for uint::range(0u, num) { |i|
result.push(i);
}
ret dvec::unwrap(result);
View
4 src/test/bench/msgsend.rs
@@ -38,11 +38,11 @@ fn run(args: [str]) {
let start = std::time::precise_time_s();
let to_child = to_child;
let mut worker_results = [];
- uint::range(0u, workers) {|_i|
+ for uint::range(0u, workers) {|_i|
let builder = task::builder();
worker_results += [task::future_result(builder)];
task::run(builder) {||
- uint::range(0u, size / workers) {|_i|
+ for uint::range(0u, size / workers) {|_i|
comm::send(to_child, bytes(100u));
}
};
View
4 src/test/bench/shootout-fasta.rs
@@ -46,7 +46,7 @@ fn make_random_fasta(id: str, desc: str, genelist: [aminoacids], n: int) {
log(debug, ">" + id + " " + desc);
let rng = @{mut last: std::rand::rng().next()};
let mut op: str = "";
- uint::range(0u, n as uint) {|_i|
+ for uint::range(0u, n as uint) {|_i|
str::push_char(op, select_random(myrandom_next(rng, 100u32),
genelist));
if str::len(op) >= LINE_LENGTH() {
@@ -61,7 +61,7 @@ fn make_repeat_fasta(id: str, desc: str, s: str, n: int) unsafe {
log(debug, ">" + id + " " + desc);
let mut op: str = "";
let sl: uint = str::len(s);
- uint::range(0u, n as uint) {|i|
+ for uint::range(0u, n as uint) {|i|
str::unsafe::push_byte(op, s[i % sl]);
if str::len(op) >= LINE_LENGTH() {
log(debug, op);
View
4 src/test/bench/shootout-mandelbrot.rs
@@ -69,7 +69,7 @@ fn chanmb(i: uint, size: uint, ch: comm::chan<line>) -> ()
let incr = 2./(size as f64);
let y = incr*(i as f64) - 1.;
let xincr = 8.*incr;
- uint::range(0_u, size/8_u) {
+ for uint::range(0_u, size/8_u) {
|j|
let x = {re: xincr*(j as f64) - 1.5, im: y};
crv += [fillbyte(x, incr)];
@@ -161,7 +161,7 @@ fn main(args: [str]) {
writer(path, writech, size);
};
let ch = comm::recv(writep);
- uint::range(0_u, size) {|j|
+ for uint::range(0_u, size) {|j|
task::spawn {|| chanmb(j, size, ch);};
if j % yieldevery == 0_u {
#debug("Y %u", j);
View
6 src/test/bench/shootout-pfib.rs
@@ -70,7 +70,7 @@ fn stress_task(&&id: int) {
fn stress(num_tasks: int) {
let mut results = [];
- range(0, num_tasks) {|i|
+ for range(0, num_tasks) {|i|
let builder = task::builder();
results += [task::future_result(builder)];
task::run(builder) {|| stress_task(i); }
@@ -99,8 +99,8 @@ fn main(args: [str]) {
let out = io::stdout();
- range(1, max + 1) {|n|
- range(0, num_trials) {|i|
+ for range(1, max + 1) {|n|
+ for range(0, num_trials) {|i|
let start = time::precise_time_ns();
let fibn = fib(n);
let stop = time::precise_time_ns();
View
2  src/test/bench/shootout-threadring.rs
@@ -8,7 +8,7 @@ fn start(+token: int) {
let p = comm::port();
let mut ch = comm::chan(p);
- int::range(2, n_threads + 1) { |i|
+ for int::range(2, n_threads + 1) { |i|
let id = n_threads + 2 - i;
let to_child = task::spawn_listener::<int> {|p, copy ch|
roundtrip(id, p, ch)
View
6 src/test/bench/std-smallintmap.rs
@@ -6,13 +6,13 @@ import std::smallintmap::{smallintmap, map};
import io::writer_util;
fn append_sequential(min: uint, max: uint, map: smallintmap<uint>) {
- uint::range(min, max) { |i|
+ for uint::range(min, max) { |i|
map.insert(i, i + 22u);
}
}
fn check_sequential(min: uint, max: uint, map: smallintmap<uint>) {
- uint::range(min, max) { |i|
+ for uint::range(min, max) { |i|
assert map.get(i) == i + 22u;
}
}
@@ -31,7 +31,7 @@ fn main(args: [str]) {
let mut checkf = 0.0;
let mut appendf = 0.0;
- uint::range(0u, rep) {|_r|
+ for uint::range(0u, rep) {|_r|
let map = smallintmap::mk();
let start = std::time::precise_time_s();
append_sequential(0u, max, map);
View
16 src/test/bench/sudoku.rs
@@ -51,7 +51,7 @@ fn solve_grid(g: grid_t) {
if start_color < 10u8 {
// colors not yet used
let avail = bitv::bitv(10u, false);
- u8::range(start_color, 10u8) { |color|
+ for u8::range(start_color, 10u8) { |color|
bitv::set(avail, color as uint, true);
}
@@ -81,7 +81,7 @@ fn solve_grid(g: grid_t) {
let it = bind drop_color(g, avail, _, _);
- u8::range(0u8, 9u8) { |idx|
+ for u8::range(0u8, 9u8) { |idx|
it(idx, col); /* check same column fields */
it(row, idx); /* check same row fields */
}
@@ -89,14 +89,14 @@ fn solve_grid(g: grid_t) {
// check same block fields
let row0 = (row / 3u8) * 3u8;
let col0 = (col / 3u8) * 3u8;
- u8::range(row0, row0 + 3u8) { |alt_row|
- u8::range(col0, col0 + 3u8) { |alt_col| it(alt_row, alt_col); }
+ for u8::range(row0, row0 + 3u8) { |alt_row|
+ for u8::range(col0, col0 + 3u8) { |alt_col| it(alt_row, alt_col); }
}
}
let mut work: [(u8, u8)] = []; /* queue of uncolored fields */
- u8::range(0u8, 9u8) { |row|
- u8::range(0u8, 9u8) { |col|
+ for u8::range(0u8, 9u8) { |row|
+ for u8::range(0u8, 9u8) { |col|
let color = (*g)[row][col];
if color == 0u8 { work += [(row, col)]; }
}
@@ -119,9 +119,9 @@ fn solve_grid(g: grid_t) {
}
fn write_grid(f: io::writer, g: grid_t) {
- u8::range(0u8, 9u8) { |row|
+ for u8::range(0u8, 9u8) { |row|
f.write_str(#fmt("%u", (*g)[row][0] as uint));
- u8::range(1u8, 9u8) { |col|
+ for u8::range(1u8, 9u8) { |col|
f.write_str(#fmt(" %u", (*g)[row][col] as uint));
}
f.write_char('\n');
View
4 src/test/bench/task-perf-vector-party.rs
@@ -4,7 +4,7 @@
// allocating and freeing vectors.
fn f(&&n: uint) {
- uint::range(0u, n) {|i|
+ for uint::range(0u, n) {|i|
let mut v: [u8] = [];
vec::reserve(v, 1000u);
}
@@ -19,5 +19,5 @@ fn main(args: [str]) {
args
};
let n = uint::from_str(args[1]).get();
- uint::range(0u, 100u) {|i| task::spawn {|| f(n); };}
+ for uint::range(0u, 100u) {|i| task::spawn {|| f(n); };}
}
View
2  src/test/compile-fail/borrowck-lend-flow.rs
@@ -65,7 +65,7 @@ fn while_aliased_mut_cond(cond: bool, cond2: bool) {
fn loop_in_block() {
let mut v = ~3, w = ~4;
let mut _x = &mut w;
- uint::range(0u, 10u) {|_i|
+ for uint::range(0u, 10u) {|_i|
borrow(v); //! ERROR loan of mutable upvar as immutable conflicts with prior loan
_x = &mut v; //! NOTE prior loan as mutable granted here
}
View
2  src/test/compile-fail/issue-1965.rs
@@ -3,5 +3,5 @@ fn test(-x: uint) {}
fn main() {
let i = 3u;
- uint::range(0u, 10u) {|_x| test(i)}
+ for uint::range(0u, 10u) {|_x| test(i)}
}
View
2  src/test/run-fail/unwind-misc-1.rs
@@ -17,7 +17,7 @@ fn main() {
let map = map::hashmap(hash, eq);
let mut arr = [];
- uint::range(0u, 10u) {|i|
+ for uint::range(0u, 10u) {|i|
arr += [@"key stuff"];
map.insert(arr, arr + [@"value stuff"]);
}
View
2  src/test/run-pass/class-cast-to-iface-multiple-types.rs
@@ -51,7 +51,7 @@ class cat implements noisy {
}
fn annoy_neighbors<T: noisy>(critter: T) {
- uint::range(0u, 10u) {|i| critter.speak(); }
+ for uint::range(0u, 10u) {|i| critter.speak(); }
}
fn main() {
View
2  src/test/run-pass/class-impl-parameterized-iface.rs
@@ -61,7 +61,7 @@ class cat implements map<int, bool> {
fn main() {
let nyan : cat = cat(0, 2, "nyan");
- uint::range(1u, 5u) {|_i| nyan.speak(); }
+ for uint::range(1u, 5u) {|_i| nyan.speak(); }
// cat returns true if uint input is greater than
// the number of meows so far
assert(nyan.get(1));
View
2  src/test/run-pass/class-implement-iface-cross-crate.rs
@@ -40,6 +40,6 @@ fn main() {
let nyan = cat(0u, 2, "nyan");
nyan.eat();
assert(!nyan.eat());
- uint::range(1u, 10u, {|_i| nyan.speak(); });
+ for uint::range(1u, 10u) {|_i| nyan.speak(); };
assert(nyan.eat());
}
View
2  src/test/run-pass/class-implement-ifaces.rs
@@ -43,6 +43,6 @@ fn main() {
let nyan = cat(0u, 2, "nyan");
nyan.eat();
assert(!nyan.eat());
- uint::range(1u, 10u, {|_i| make_speak(nyan); });
+ for uint::range(1u, 10u) {|_i| make_speak(nyan); };
assert(nyan.eat());
}
View
2  src/test/run-pass/class-implements-multiple-ifaces.rs
@@ -84,7 +84,7 @@ class cat implements noisy, scratchy, bitey {
}
fn annoy_neighbors<T: noisy>(critter: T) {
- uint::range(0u, 10u) {|i|
+ for uint::range(0u, 10u) {|i|
let what = critter.speak();
#debug("%u %d", i, what);
}
View
2  src/test/run-pass/classes-cross-crate.rs
@@ -7,6 +7,6 @@ fn main() {
let nyan = cat(0u, 2, "nyan");
nyan.eat();
assert(!nyan.eat());
- uint::range(1u, 10u, {|_i| nyan.speak(); });
+ for uint::range(1u, 10u) {|_i| nyan.speak(); };
assert(nyan.eat());
}
View
2  src/test/run-pass/classes.rs
@@ -35,6 +35,6 @@ fn main() {
let nyan = cat(0u, 2, "nyan");
nyan.eat();
assert(!nyan.eat());
- uint::range(1u, 10u, {|_i| nyan.speak(); });
+ for uint::range(1u, 10u) {|_i| nyan.speak(); };
assert(nyan.eat());
}
View
10 src/test/run-pass/issue-2185.rs
@@ -28,8 +28,16 @@ fn foldl<A,B,IA:iterable<A>>(self: IA, +b0: B, blk: fn(B, A) -> B) -> B {
ret b;
}
+fn range(lo: uint, hi: uint, it: fn(uint)) {
+ let mut i = lo;
+ while i < hi {
+ it(i);
+ i += 1u;
+ }
+}
+
fn main() {
- let range = bind uint::range(0u, 1000u, _);
+ let range = bind range(0u, 1000u, _);
let filt = bind filter(
range,
{|&&n: uint| n % 3u != 0u && n % 5u != 0u },
View
2  src/test/run-pass/lots-a-fail.rs
@@ -13,7 +13,7 @@ fn iloop() {
}
fn main() {
- uint::range(0u, 100u) {|_i|
+ for uint::range(0u, 100u) {|_i|
let builder = task::builder();
task::unsupervise(builder);
task::run(builder) {|| iloop(); };
View
2  src/test/run-pass/move-3-unique.rs
@@ -10,7 +10,7 @@ fn test(x: bool, foo: ~{x: int, y: int, z: int}) -> int {
fn main() {
let x = ~{x: 1, y: 2, z: 3};
- uint::range(0u, 10000u) {|_i|
+ for uint::range(0u, 10000u) {|_i|
assert (test(true, x) == 2);
}
assert (test(false, x) == 5);
View
2  src/test/run-pass/move-3.rs
@@ -10,7 +10,7 @@ fn test(x: bool, foo: @{x: int, y: int, z: int}) -> int {
fn main() {
let x = @{x: 1, y: 2, z: 3};
- uint::range(0u, 10000u) {|i|
+ for uint::range(0u, 10000u) {|i|
assert (test(true, x) == 2);
}
assert (test(false, x) == 5);
View
2  src/test/run-pass/pattern-bound-var-in-for-each.rs
@@ -6,7 +6,7 @@ fn foo(src: uint) {
alt some(src) {
some(src_id) {
- uint::range(0u, 10u) {|i|
+ for uint::range(0u, 10u) {|i|
let yyy = src_id;
assert (yyy == 0u);
}
View
2  src/test/run-pass/private-method.rs
@@ -1,7 +1,7 @@
class cat {
priv {
let mut meows : uint;
- fn nap() { uint::range(1u, 10u) {|_i|}}
+ fn nap() { for uint::range(1u, 10u) {|_i|}}
}
let how_hungry : int;
View
14 src/test/run-pass/rt-circular-buffer.rs
@@ -32,7 +32,7 @@ fn test_init() {
fn test_grow() {
let myport = port();
let mychan = chan(myport);
- uint::range(0u, 100u) {|i|
+ for uint::range(0u, 100u) {|i|
let val: record = {val1: 0u32, val2: 0u32, val3: 0u32};
comm::send(mychan, val);
}
@@ -50,11 +50,11 @@ fn test_shrink1() {
fn test_shrink2() {
let myport = port();
let mychan = chan(myport);
- uint::range(0u, 100u) {|_i|
+ for uint::range(0u, 100u) {|_i|
let val: record = {val1: 0u32, val2: 0u32, val3: 0u32};
send(mychan, val);
}
- uint::range(0u, 100u) {|_i| let x = recv(myport); }
+ for uint::range(0u, 100u) {|_i| let x = recv(myport); }
}
@@ -62,7 +62,7 @@ fn test_shrink2() {
fn test_rotate() {
let myport = port();
let mychan = chan(myport);
- uint::range(0u, 100u) {|i|
+ for uint::range(0u, 100u) {|i|
let val = {val1: i as u32, val2: i as u32, val3: i as u32};
send(mychan, val);
let x = recv(myport);
@@ -78,13 +78,13 @@ fn test_rotate() {
fn test_rotate_grow() {
let myport = port::<record>();
let mychan = chan(myport);
- uint::range(0u, 10u) {|j|
- uint::range(0u, 10u) {|i|
+ for uint::range(0u, 10u) {|j|
+ for uint::range(0u, 10u) {|i|
let val: record =
{val1: i as u32, val2: i as u32, val3: i as u32};
send(mychan, val);
}
- uint::range(0u, 10u) {|i|
+ for uint::range(0u, 10u) {|i|
let x = recv(myport);
assert (x.val1 == i as u32);
assert (x.val2 == i as u32);
View
2  src/test/run-pass/send-iloop.rs
@@ -21,7 +21,7 @@ fn iloop() {
}
fn main() {
- uint::range(0u, 16u) {|_i|
+ for uint::range(0u, 16u) {|_i|
let builder = task::builder();
task::unsupervise(builder);
task::run(builder) {|| iloop(); }
View
6 src/test/run-pass/task-comm-chan-cleanup4.rs
@@ -7,13 +7,13 @@ import task;
// results in the string not being freed
fn starship(&&ch: comm::chan<str>) {
- int::range(0, 10) { |_i|
+ for int::range(0, 10) { |_i|
comm::send(ch, "pew pew");
}
}
fn starbase() {
- int::range(0, 10) { |_i|
+ for int::range(0, 10) { |_i|
let p = comm::port();
let c = comm::chan(p);
task::spawn {|| starship(c);};
@@ -22,7 +22,7 @@ fn starbase() {
}
fn main() {
- int::range(0, 10) { |_i|
+ for int::range(0, 10) { |_i|
task::spawn {|| starbase();};
}
}
View
4 src/test/run-pass/unique-send-2.rs
@@ -12,13 +12,13 @@ fn main() {
let ch = comm::chan(p);
let n = 100u;
let mut expected = 0u;
- uint::range(0u, n) {|i|
+ for uint::range(0u, n) {|i|
task::spawn {|| child(ch, i); };
expected += i;
}
let mut actual = 0u;
- uint::range(0u, n) {|_i|
+ for uint::range(0u, n) {|_i|
let j = comm::recv(p);
actual += *j;
}
Please sign in to comment.
Something went wrong with that request. Please try again.