Remove Times trait

`Times::times` was always a second-class loop because it did not support the `break` and `continue` operations. Its playful appeal was then lost after `do` was disabled for closures. It's time to let this one go.
This commit is contained in:
Brendan Zabarauskas
2014-01-30 11:20:34 +11:00
parent dfb61166f5
commit 729060dbb9
47 changed files with 151 additions and 200 deletions

View File

@@ -14,6 +14,7 @@ use codemap;
use std::cell::Cell;
use std::io;
use std::io::stdio::StdWriter;
use std::iter::range;
use std::local_data;
use extra::term;
@@ -320,7 +321,7 @@ fn highlight_lines(cm: &codemap::CodeMap,
// Skip is the number of characters we need to skip because they are
// part of the 'filename:line ' part of the previous line.
let skip = fm.name.len() + digits + 3u;
skip.times(|| s.push_char(' '));
for _ in range(0, skip) { s.push_char(' '); }
let orig = fm.get_line(lines.lines[0] as int);
for pos in range(0u, left-skip) {
let curChar = (orig[pos] as char);
@@ -339,7 +340,7 @@ fn highlight_lines(cm: &codemap::CodeMap,
if hi.col != lo.col {
// the ^ already takes up one space
let num_squigglies = hi.col.to_uint()-lo.col.to_uint()-1u;
num_squigglies.times(|| s.push_char('~'));
for _ in range(0, num_squigglies) { s.push_char('~'); }
}
print_maybe_styled(s + "\n", term::attr::ForegroundColor(lvl.color()));
}
@@ -378,7 +379,7 @@ fn custom_highlight_lines(cm: &codemap::CodeMap,
// Span seems to use half-opened interval, so subtract 1
let skip = last_line_start.len() + hi.col.to_uint() - 1;
let mut s = ~"";
skip.times(|| s.push_char(' '));
for _ in range(0, skip) { s.push_char(' '); }
s.push_char('^');
print_maybe_styled(s + "\n", term::attr::ForegroundColor(lvl.color()));
}

View File

@@ -396,9 +396,9 @@ pub fn parse(sess: @ParseSess,
}
cur_eis.push(ei);
rust_parser.tokens_consumed.times(|| {
for _ in range(0, rust_parser.tokens_consumed) {
let _ = rdr.next_token();
});
}
}
}