replace range
with an external iterator
This commit is contained in:
parent
5890fcf872
commit
234acad404
117 changed files with 336 additions and 442 deletions
|
@ -2386,9 +2386,8 @@ foreach e in v.iter() {
|
|||
An example of a for loop over a series of integers:
|
||||
|
||||
~~~~
|
||||
# use std::uint;
|
||||
# fn bar(b:uint) { }
|
||||
for uint::range(0, 256) |i| {
|
||||
foreach i in range(0u, 256) {
|
||||
bar(i);
|
||||
}
|
||||
~~~~
|
||||
|
|
|
@ -120,9 +120,8 @@ should interleave the output in vaguely random order.
|
|||
~~~
|
||||
# use std::io::print;
|
||||
# use std::task::spawn;
|
||||
# use std::int;
|
||||
|
||||
for int::range(0, 20) |child_task_number| {
|
||||
foreach child_task_number in range(0, 20) {
|
||||
do spawn {
|
||||
print(fmt!("I am child number %d\n", child_task_number));
|
||||
}
|
||||
|
@ -237,12 +236,11 @@ Instead we can use a `SharedChan`, a type that allows a single
|
|||
~~~
|
||||
# use std::task::spawn;
|
||||
# use std::comm::{stream, SharedChan};
|
||||
# use std::uint;
|
||||
|
||||
let (port, chan) = stream();
|
||||
let chan = SharedChan::new(chan);
|
||||
|
||||
for uint::range(0, 3) |init_val| {
|
||||
foreach init_val in range(0u, 3) {
|
||||
// Create a new channel handle to distribute to the child task
|
||||
let child_chan = chan.clone();
|
||||
do spawn {
|
||||
|
@ -314,10 +312,9 @@ Here is another example showing how futures allow you to background computations
|
|||
be distributed on the available cores.
|
||||
~~~
|
||||
# use std::vec;
|
||||
# use std::uint;
|
||||
fn partial_sum(start: uint) -> f64 {
|
||||
let mut local_sum = 0f64;
|
||||
for uint::range(start*100000, (start+1)*100000) |num| {
|
||||
foreach num in range(start*100000, (start+1)*100000) {
|
||||
local_sum += (num as f64 + 1.0).pow(&-2.0);
|
||||
}
|
||||
local_sum
|
||||
|
@ -349,7 +346,6 @@ Here is a small example showing how to use Arcs. We wish to run concurrently sev
|
|||
a single large vector of floats. Each task needs the full vector to perform its duty.
|
||||
~~~
|
||||
# use std::vec;
|
||||
# use std::uint;
|
||||
# use std::rand;
|
||||
use extra::arc::Arc;
|
||||
|
||||
|
@ -363,7 +359,7 @@ fn main() {
|
|||
|
||||
let numbers_arc = Arc::new(numbers);
|
||||
|
||||
for uint::range(1,10) |num| {
|
||||
foreach num in range(1u, 10) {
|
||||
let (port, chan) = stream();
|
||||
chan.send(numbers_arc.clone());
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ use util::logv;
|
|||
use std::io;
|
||||
use std::os;
|
||||
use std::str;
|
||||
use std::uint;
|
||||
use std::vec;
|
||||
|
||||
use extra::test::MetricMap;
|
||||
|
@ -414,7 +413,7 @@ fn check_expected_errors(expected_errors: ~[errors::ExpectedError],
|
|||
}
|
||||
}
|
||||
|
||||
for uint::range(0u, found_flags.len()) |i| {
|
||||
foreach i in range(0u, found_flags.len()) {
|
||||
if !found_flags[i] {
|
||||
let ee = &expected_errors[i];
|
||||
fatal_ProcRes(fmt!("expected %s on line %u not found: %s",
|
||||
|
|
|
@ -566,7 +566,6 @@ mod tests {
|
|||
use std::cell::Cell;
|
||||
use std::comm;
|
||||
use std::task;
|
||||
use std::uint;
|
||||
|
||||
#[test]
|
||||
fn manually_share_arc() {
|
||||
|
@ -851,7 +850,7 @@ mod tests {
|
|||
*state = 31337;
|
||||
// FIXME: #7372: hits type inference bug with iterators
|
||||
// send to other readers
|
||||
for uint::range(0, reader_convos.len()) |i| {
|
||||
foreach i in range(0u, reader_convos.len()) {
|
||||
match reader_convos[i] {
|
||||
(ref rc, _) => rc.send(()),
|
||||
}
|
||||
|
@ -861,7 +860,7 @@ mod tests {
|
|||
do (&read_mode).read |state| {
|
||||
// FIXME: #7372: hits type inference bug with iterators
|
||||
// complete handshake with other readers
|
||||
for uint::range(0, reader_convos.len()) |i| {
|
||||
foreach i in range(0u, reader_convos.len()) {
|
||||
match reader_convos[i] {
|
||||
(_, ref rp) => rp.recv(),
|
||||
}
|
||||
|
|
|
@ -277,7 +277,7 @@ impl Arena {
|
|||
#[test]
|
||||
fn test_arena_destructors() {
|
||||
let arena = Arena();
|
||||
for uint::range(0, 10) |i| {
|
||||
foreach i in range(0u, 10) {
|
||||
// Arena allocate something with drop glue to make sure it
|
||||
// doesn't leak.
|
||||
do arena.alloc { @i };
|
||||
|
@ -293,7 +293,7 @@ fn test_arena_destructors() {
|
|||
fn test_arena_destructors_fail() {
|
||||
let arena = Arena();
|
||||
// Put some stuff in the arena.
|
||||
for uint::range(0, 10) |i| {
|
||||
foreach i in range(0u, 10) {
|
||||
// Arena allocate something with drop glue to make sure it
|
||||
// doesn't leak.
|
||||
do arena.alloc { @i };
|
||||
|
|
|
@ -19,7 +19,6 @@ use std::ops;
|
|||
use std::uint;
|
||||
use std::vec;
|
||||
|
||||
|
||||
#[deriving(Clone)]
|
||||
struct SmallBitv {
|
||||
/// only the lowest nbits of this value are used. the rest is undefined.
|
||||
|
@ -146,7 +145,7 @@ impl BigBitv {
|
|||
let len = b.storage.len();
|
||||
assert_eq!(self.storage.len(), len);
|
||||
let mut changed = false;
|
||||
for uint::range(0, len) |i| {
|
||||
foreach i in range(0, len) {
|
||||
let mask = big_mask(nbits, i);
|
||||
let w0 = self.storage[i] & mask;
|
||||
let w1 = b.storage[i] & mask;
|
||||
|
@ -161,7 +160,7 @@ impl BigBitv {
|
|||
|
||||
#[inline]
|
||||
pub fn each_storage(&mut self, op: &fn(v: &mut uint) -> bool) -> bool {
|
||||
uint::range(0, self.storage.len(), |i| op(&mut self.storage[i]))
|
||||
range(0u, self.storage.len()).advance(|i| op(&mut self.storage[i]))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
@ -511,7 +510,7 @@ impl Bitv {
|
|||
}
|
||||
|
||||
pub fn ones(&self, f: &fn(uint) -> bool) -> bool {
|
||||
uint::range(0, self.nbits, |i| !self.get(i) || f(i))
|
||||
range(0u, self.nbits).advance(|i| !self.get(i) || f(i))
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -542,7 +541,7 @@ pub fn from_bools(bools: &[bool]) -> Bitv {
|
|||
*/
|
||||
pub fn from_fn(len: uint, f: &fn(index: uint) -> bool) -> Bitv {
|
||||
let mut bitv = Bitv::new(len, false);
|
||||
for uint::range(0, len) |i| {
|
||||
foreach i in range(0u, len) {
|
||||
bitv.set(i, f(i));
|
||||
}
|
||||
bitv
|
||||
|
@ -559,7 +558,7 @@ fn iterate_bits(base: uint, bits: uint, f: &fn(uint) -> bool) -> bool {
|
|||
if bits == 0 {
|
||||
return true;
|
||||
}
|
||||
for uint::range(0, uint::bits) |i| {
|
||||
foreach i in range(0u, uint::bits) {
|
||||
if bits & (1 << i) != 0 {
|
||||
if !f(base + i) {
|
||||
return false;
|
||||
|
@ -674,7 +673,7 @@ impl BitvSet {
|
|||
fn other_op(&mut self, other: &BitvSet, f: &fn(uint, uint) -> uint) {
|
||||
fn nbits(mut w: uint) -> uint {
|
||||
let mut bits = 0;
|
||||
for uint::range(0, uint::bits) |_| {
|
||||
foreach _ in range(0u, uint::bits) {
|
||||
if w == 0 {
|
||||
break;
|
||||
}
|
||||
|
@ -1283,12 +1282,12 @@ mod tests {
|
|||
#[test]
|
||||
fn test_equal_sneaky_big() {
|
||||
let mut a = bitv::Bitv::new(100, false);
|
||||
for uint::range(0, 100) |i| {
|
||||
foreach i in range(0u, 100) {
|
||||
a.set(i, true);
|
||||
}
|
||||
|
||||
let mut b = bitv::Bitv::new(100, true);
|
||||
for uint::range(0, 100) |i| {
|
||||
foreach i in range(0u, 100) {
|
||||
b.set(i, true);
|
||||
}
|
||||
|
||||
|
|
|
@ -41,9 +41,8 @@ pub trait Deque<T> : Mutable {
|
|||
|
||||
#[cfg(test)]
|
||||
mod bench {
|
||||
|
||||
use std::container::MutableMap;
|
||||
use std::{vec,rand,uint};
|
||||
use std::{vec, rand};
|
||||
use std::rand::RngUtil;
|
||||
use test::BenchHarness;
|
||||
|
||||
|
@ -54,7 +53,7 @@ mod bench {
|
|||
let mut rng = rand::XorShiftRng::new();
|
||||
|
||||
map.clear();
|
||||
for uint::range(0,n) |_i| {
|
||||
foreach _ in range(0, n) {
|
||||
map.insert(rng.gen::<uint>() % n, 1);
|
||||
}
|
||||
|
||||
|
@ -71,7 +70,7 @@ mod bench {
|
|||
bh: &mut BenchHarness) {
|
||||
// setup
|
||||
map.clear();
|
||||
for uint::range(0, n) |i| {
|
||||
foreach i in range(0u, n) {
|
||||
map.insert(i*2, 1);
|
||||
}
|
||||
|
||||
|
@ -109,7 +108,7 @@ mod bench {
|
|||
map: &mut M,
|
||||
bh: &mut BenchHarness) {
|
||||
// setup
|
||||
for uint::range(0, n) |i| {
|
||||
foreach i in range(0u, n) {
|
||||
map.insert(i, 1);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,9 +8,6 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
|
||||
use std::uint;
|
||||
|
||||
use digest::Digest;
|
||||
|
||||
// BitCounter is a specialized structure intended simply for counting the
|
||||
|
@ -169,7 +166,7 @@ impl Engine512 {
|
|||
((x << 45) | (x >> 19)) ^ ((x << 3) | (x >> 61)) ^ (x >> 6)
|
||||
}
|
||||
|
||||
for uint::range(16, 80) |t| {
|
||||
foreach t in range(16u, 80) {
|
||||
self.W[t] = sigma1(self.W[t - 2]) + self.W[t - 7] + sigma0(self.W[t - 15]) +
|
||||
self.W[t - 16];
|
||||
}
|
||||
|
@ -184,7 +181,7 @@ impl Engine512 {
|
|||
let mut h = self.H7;
|
||||
|
||||
let mut t = 0;
|
||||
for uint::range(0, 10) |_| {
|
||||
foreach _ in range(0u, 10) {
|
||||
h += sum1(e) + ch(e, f, g) + K64[t] + self.W[t];
|
||||
d += h;
|
||||
h += sum0(a) + maj(a, b, c);
|
||||
|
@ -254,7 +251,7 @@ impl Engine512 {
|
|||
|
||||
// add length
|
||||
if (self.W_idx > 14) {
|
||||
for uint::range(self.W_idx, 16) |_| {
|
||||
foreach _ in range(self.W_idx, 16) {
|
||||
self.process_word(0);
|
||||
}
|
||||
}
|
||||
|
@ -452,7 +449,7 @@ impl Engine256 {
|
|||
((x >> 17) | (x << 15)) ^ ((x >> 19) | (x << 13)) ^ (x >> 10)
|
||||
}
|
||||
|
||||
for uint::range(16, 64) |t| {
|
||||
foreach t in range(16u, 64) {
|
||||
self.W[t] = sigma1(self.W[t - 2]) + self.W[t - 7] + sigma0(self.W[t - 15]) +
|
||||
self.W[t - 16];
|
||||
}
|
||||
|
@ -467,7 +464,7 @@ impl Engine256 {
|
|||
let mut h = self.H7;
|
||||
|
||||
let mut t = 0;
|
||||
for uint::range(0, 8) |_| {
|
||||
foreach _ in range(0u, 8) {
|
||||
h += sum1(e) + ch(e, f, g) + K32[t] + self.W[t];
|
||||
d += h;
|
||||
h += sum0(a) + maj(a, b, c);
|
||||
|
@ -536,7 +533,7 @@ impl Engine256 {
|
|||
|
||||
// add length
|
||||
if (self.W_idx > 14) {
|
||||
for uint::range(self.W_idx, 16) |_| {
|
||||
foreach _ in range(self.W_idx, 16) {
|
||||
self.process_word(0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -607,7 +607,6 @@ pub fn check_links<T>(list: &DList<T>) {
|
|||
mod tests {
|
||||
use super::*;
|
||||
use std::rand;
|
||||
use std::int;
|
||||
use extra::test;
|
||||
|
||||
#[test]
|
||||
|
@ -944,7 +943,7 @@ mod tests {
|
|||
fn fuzz_test(sz: int) {
|
||||
let mut m = DList::new::<int>();
|
||||
let mut v = ~[];
|
||||
for int::range(0i, sz) |i| {
|
||||
foreach i in range(0, sz) {
|
||||
check_links(&m);
|
||||
let r: u8 = rand::random();
|
||||
match r % 6 {
|
||||
|
|
|
@ -596,7 +596,7 @@ mod test {
|
|||
input.next_file(); // skip the rest of 1
|
||||
|
||||
// read all lines from 1 (but don't read any from 2),
|
||||
for uint::range(1, 4) |i| {
|
||||
foreach i in range(1u, 4) {
|
||||
assert_eq!(input.read_line(), fmt!("1 %u", i));
|
||||
}
|
||||
// 1 is finished, but 2 hasn't been started yet, so this will
|
||||
|
|
|
@ -29,12 +29,12 @@ This example sends boxed integers across tasks using serialization.
|
|||
let (port, chan) = serial::pipe_stream();
|
||||
|
||||
do task::spawn || {
|
||||
for int::range(0, 10) |i| {
|
||||
foreach i in range(0, 10) {
|
||||
chan.send(@i)
|
||||
}
|
||||
}
|
||||
|
||||
for int::range(0, 10) |i| {
|
||||
foreach i in range(0, 10) {
|
||||
assert @i == port.recv()
|
||||
}
|
||||
~~~
|
||||
|
@ -641,7 +641,6 @@ mod test {
|
|||
use flatpipes::{BytePort, FlatChan, FlatPort};
|
||||
|
||||
use std::comm;
|
||||
use std::int;
|
||||
use std::io::BytesWriter;
|
||||
use std::result;
|
||||
use std::task;
|
||||
|
@ -669,12 +668,12 @@ mod test {
|
|||
let (port, chan) = serial::pipe_stream();
|
||||
|
||||
do task::spawn || {
|
||||
for int::range(0, 10) |i| {
|
||||
foreach i in range(0, 10) {
|
||||
chan.send(i)
|
||||
}
|
||||
}
|
||||
|
||||
for int::range(0, 10) |i| {
|
||||
foreach i in range(0, 10) {
|
||||
assert!(i == port.recv())
|
||||
}
|
||||
}
|
||||
|
@ -685,12 +684,12 @@ mod test {
|
|||
let (port, chan) = serial::pipe_stream();
|
||||
|
||||
do task::spawn || {
|
||||
for int::range(0, 10) |i| {
|
||||
foreach i in range(0, 10) {
|
||||
chan.send(@i)
|
||||
}
|
||||
}
|
||||
|
||||
for int::range(0, 10) |i| {
|
||||
foreach i in range(0, 10) {
|
||||
assert!(@i == port.recv())
|
||||
}
|
||||
}
|
||||
|
@ -716,12 +715,12 @@ mod test {
|
|||
let (port, chan) = pod::pipe_stream();
|
||||
|
||||
do task::spawn || {
|
||||
for int::range(0, 10) |i| {
|
||||
foreach i in range(0, 10) {
|
||||
chan.send(i)
|
||||
}
|
||||
}
|
||||
|
||||
for int::range(0, 10) |i| {
|
||||
foreach i in range(0, 10) {
|
||||
assert!(i == port.recv())
|
||||
}
|
||||
}
|
||||
|
@ -827,7 +826,7 @@ mod test {
|
|||
// TcpSocketBuf is a Writer!
|
||||
let chan = writer_chan(socket_buf);
|
||||
|
||||
for int::range(0, 10) |i| {
|
||||
foreach i in range(0, 10) {
|
||||
debug!("sending %?", i);
|
||||
chan.send(i)
|
||||
}
|
||||
|
@ -850,7 +849,7 @@ mod test {
|
|||
// TcpSocketBuf is a Reader!
|
||||
let port = reader_port(socket_buf);
|
||||
|
||||
for int::range(0, 10) |i| {
|
||||
foreach i in range(0, 10) {
|
||||
let j = port.recv();
|
||||
debug!("received %?", j);
|
||||
assert_eq!(i, j);
|
||||
|
|
|
@ -1608,7 +1608,7 @@ mod biguint_tests {
|
|||
fn test_factor() {
|
||||
fn factor(n: uint) -> BigUint {
|
||||
let mut f= One::one::<BigUint>();
|
||||
for uint::range(2, n + 1) |i| {
|
||||
foreach i in range(2, n + 1) {
|
||||
// FIXME(#6102): Assignment operator for BigInt causes ICE
|
||||
// f *= BigUint::from_uint(i);
|
||||
f = f * BigUint::from_uint(i);
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
//! extra::container::Deque`.
|
||||
|
||||
use std::num;
|
||||
use std::uint;
|
||||
use std::vec;
|
||||
use std::iterator::{FromIterator, Invert, RandomAccessIterator, Extendable};
|
||||
|
||||
|
@ -278,7 +277,7 @@ fn grow<T>(nelts: uint, loptr: &mut uint, elts: &mut ~[Option<T>]) {
|
|||
elts.reserve(newlen);
|
||||
|
||||
/* fill with None */
|
||||
for uint::range(elts.len(), elts.capacity()) |_| {
|
||||
foreach _ in range(elts.len(), elts.capacity()) {
|
||||
elts.push(None);
|
||||
}
|
||||
|
||||
|
@ -293,11 +292,11 @@ fn grow<T>(nelts: uint, loptr: &mut uint, elts: &mut ~[Option<T>]) {
|
|||
|
||||
assert!(newlen - nelts/2 >= nelts);
|
||||
if lo <= (nelts - lo) { // A
|
||||
for uint::range(0, lo) |i| {
|
||||
foreach i in range(0u, lo) {
|
||||
elts.swap(i, nelts + i);
|
||||
}
|
||||
} else { // B
|
||||
for uint::range(lo, nelts) |i| {
|
||||
foreach i in range(lo, nelts) {
|
||||
elts.swap(i, newlen - nelts + i);
|
||||
}
|
||||
*loptr += newlen - nelts;
|
||||
|
@ -345,7 +344,6 @@ mod tests {
|
|||
use super::*;
|
||||
use std::clone::Clone;
|
||||
use std::cmp::Eq;
|
||||
use std::{int, uint};
|
||||
use extra::test;
|
||||
|
||||
#[test]
|
||||
|
@ -463,21 +461,21 @@ mod tests {
|
|||
#[test]
|
||||
fn test_push_front_grow() {
|
||||
let mut deq = RingBuf::new();
|
||||
for uint::range(0, 66) |i| {
|
||||
foreach i in range(0u, 66) {
|
||||
deq.push_front(i);
|
||||
}
|
||||
assert_eq!(deq.len(), 66);
|
||||
|
||||
for uint::range(0, 66) |i| {
|
||||
foreach i in range(0u, 66) {
|
||||
assert_eq!(*deq.get(i), 65 - i);
|
||||
}
|
||||
|
||||
let mut deq = RingBuf::new();
|
||||
for uint::range(0, 66) |i| {
|
||||
foreach i in range(0u, 66) {
|
||||
deq.push_back(i);
|
||||
}
|
||||
|
||||
for uint::range(0, 66) |i| {
|
||||
foreach i in range(0u, 66) {
|
||||
assert_eq!(*deq.get(i), i);
|
||||
}
|
||||
}
|
||||
|
@ -608,12 +606,12 @@ mod tests {
|
|||
assert_eq!(d.iter().next(), None);
|
||||
assert_eq!(d.iter().size_hint(), (0, Some(0)));
|
||||
|
||||
for int::range(0,5) |i| {
|
||||
foreach i in range(0, 5) {
|
||||
d.push_back(i);
|
||||
}
|
||||
assert_eq!(d.iter().collect::<~[&int]>(), ~[&0,&1,&2,&3,&4]);
|
||||
|
||||
for int::range(6,9) |i| {
|
||||
foreach i in range(6, 9) {
|
||||
d.push_front(i);
|
||||
}
|
||||
assert_eq!(d.iter().collect::<~[&int]>(), ~[&8,&7,&6,&0,&1,&2,&3,&4]);
|
||||
|
@ -633,12 +631,12 @@ mod tests {
|
|||
let mut d = RingBuf::new();
|
||||
assert_eq!(d.rev_iter().next(), None);
|
||||
|
||||
for int::range(0,5) |i| {
|
||||
foreach i in range(0, 5) {
|
||||
d.push_back(i);
|
||||
}
|
||||
assert_eq!(d.rev_iter().collect::<~[&int]>(), ~[&4,&3,&2,&1,&0]);
|
||||
|
||||
for int::range(6,9) |i| {
|
||||
foreach i in range(6, 9) {
|
||||
d.push_front(i);
|
||||
}
|
||||
assert_eq!(d.rev_iter().collect::<~[&int]>(), ~[&4,&3,&2,&1,&0,&6,&7,&8]);
|
||||
|
@ -649,7 +647,7 @@ mod tests {
|
|||
let mut d = RingBuf::new();
|
||||
assert!(d.mut_iter().next().is_none());
|
||||
|
||||
for uint::range(0,3) |i| {
|
||||
foreach i in range(0u, 3) {
|
||||
d.push_front(i);
|
||||
}
|
||||
|
||||
|
@ -672,7 +670,7 @@ mod tests {
|
|||
let mut d = RingBuf::new();
|
||||
assert!(d.mut_rev_iter().next().is_none());
|
||||
|
||||
for uint::range(0,3) |i| {
|
||||
foreach i in range(0u, 3) {
|
||||
d.push_front(i);
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@ Core encoding and decoding interfaces.
|
|||
use std::at_vec;
|
||||
use std::hashmap::{HashMap, HashSet};
|
||||
use std::trie::{TrieMap, TrieSet};
|
||||
use std::uint;
|
||||
use std::vec;
|
||||
use ringbuf::RingBuf;
|
||||
use container::Deque;
|
||||
|
@ -679,7 +678,7 @@ impl<D:Decoder,T:Decodable<D>> Decodable<D> for DList<T> {
|
|||
fn decode(d: &mut D) -> DList<T> {
|
||||
let mut list = DList::new();
|
||||
do d.read_seq |d, len| {
|
||||
for uint::range(0, len) |i| {
|
||||
foreach i in range(0u, len) {
|
||||
list.push_back(d.read_seq_elt(i, |d| Decodable::decode(d)));
|
||||
}
|
||||
}
|
||||
|
@ -704,7 +703,7 @@ impl<D:Decoder,T:Decodable<D>> Decodable<D> for RingBuf<T> {
|
|||
fn decode(d: &mut D) -> RingBuf<T> {
|
||||
let mut deque = RingBuf::new();
|
||||
do d.read_seq |d, len| {
|
||||
for uint::range(0, len) |i| {
|
||||
foreach i in range(0u, len) {
|
||||
deque.push_back(d.read_seq_elt(i, |d| Decodable::decode(d)));
|
||||
}
|
||||
}
|
||||
|
@ -737,7 +736,7 @@ impl<
|
|||
fn decode(d: &mut D) -> HashMap<K, V> {
|
||||
do d.read_map |d, len| {
|
||||
let mut map = HashMap::with_capacity(len);
|
||||
for uint::range(0, len) |i| {
|
||||
foreach i in range(0u, len) {
|
||||
let key = d.read_map_elt_key(i, |d| Decodable::decode(d));
|
||||
let val = d.read_map_elt_val(i, |d| Decodable::decode(d));
|
||||
map.insert(key, val);
|
||||
|
@ -769,7 +768,7 @@ impl<
|
|||
fn decode(d: &mut D) -> HashSet<T> {
|
||||
do d.read_seq |d, len| {
|
||||
let mut set = HashSet::with_capacity(len);
|
||||
for uint::range(0, len) |i| {
|
||||
foreach i in range(0u, len) {
|
||||
set.insert(d.read_seq_elt(i, |d| Decodable::decode(d)));
|
||||
}
|
||||
set
|
||||
|
@ -801,7 +800,7 @@ impl<
|
|||
fn decode(d: &mut D) -> TrieMap<V> {
|
||||
do d.read_map |d, len| {
|
||||
let mut map = TrieMap::new();
|
||||
for uint::range(0, len) |i| {
|
||||
foreach i in range(0u, len) {
|
||||
let key = d.read_map_elt_key(i, |d| Decodable::decode(d));
|
||||
let val = d.read_map_elt_val(i, |d| Decodable::decode(d));
|
||||
map.insert(key, val);
|
||||
|
@ -828,7 +827,7 @@ impl<D: Decoder> Decodable<D> for TrieSet {
|
|||
fn decode(d: &mut D) -> TrieSet {
|
||||
do d.read_seq |d, len| {
|
||||
let mut set = TrieSet::new();
|
||||
for uint::range(0, len) |i| {
|
||||
foreach i in range(0u, len) {
|
||||
set.insert(d.read_seq_elt(i, |d| Decodable::decode(d)));
|
||||
}
|
||||
set
|
||||
|
@ -861,7 +860,7 @@ impl<
|
|||
fn decode(d: &mut D) -> TreeMap<K, V> {
|
||||
do d.read_map |d, len| {
|
||||
let mut map = TreeMap::new();
|
||||
for uint::range(0, len) |i| {
|
||||
foreach i in range(0u, len) {
|
||||
let key = d.read_map_elt_key(i, |d| Decodable::decode(d));
|
||||
let val = d.read_map_elt_val(i, |d| Decodable::decode(d));
|
||||
map.insert(key, val);
|
||||
|
@ -893,7 +892,7 @@ impl<
|
|||
fn decode(d: &mut D) -> TreeSet<T> {
|
||||
do d.read_seq |d, len| {
|
||||
let mut set = TreeSet::new();
|
||||
for uint::range(0, len) |i| {
|
||||
foreach i in range(0u, len) {
|
||||
set.insert(d.read_seq_elt(i, |d| Decodable::decode(d)));
|
||||
}
|
||||
set
|
||||
|
|
|
@ -30,7 +30,7 @@ impl<V> Container for SmallIntMap<V> {
|
|||
/// Return the number of elements in the map
|
||||
fn len(&self) -> uint {
|
||||
let mut sz = 0;
|
||||
for uint::range(0, self.v.len()) |i| {
|
||||
foreach i in range(0u, self.v.len()) {
|
||||
match self.v[i] {
|
||||
Some(_) => sz += 1,
|
||||
None => {}
|
||||
|
@ -123,13 +123,13 @@ impl<V> SmallIntMap<V> {
|
|||
|
||||
/// Visit all key-value pairs in order
|
||||
pub fn each<'a>(&'a self, it: &fn(&uint, &'a V) -> bool) -> bool {
|
||||
for uint::range(0, self.v.len()) |i| {
|
||||
foreach i in range(0u, self.v.len()) {
|
||||
match self.v[i] {
|
||||
Some(ref elt) => if !it(&i, elt) { return false; },
|
||||
None => ()
|
||||
}
|
||||
}
|
||||
return true;
|
||||
true
|
||||
}
|
||||
|
||||
/// Visit all keys in order
|
||||
|
@ -144,13 +144,13 @@ impl<V> SmallIntMap<V> {
|
|||
|
||||
/// Iterate over the map and mutate the contained values
|
||||
pub fn mutate_values(&mut self, it: &fn(&uint, &mut V) -> bool) -> bool {
|
||||
for uint::range(0, self.v.len()) |i| {
|
||||
foreach i in range(0, self.v.len()) {
|
||||
match self.v[i] {
|
||||
Some(ref mut elt) => if !it(&i, elt) { return false; },
|
||||
None => ()
|
||||
}
|
||||
}
|
||||
return true;
|
||||
true
|
||||
}
|
||||
|
||||
/// Visit all key-value pairs in reverse order
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
|
||||
|
||||
use std::cmp::{Eq, Ord};
|
||||
use std::uint;
|
||||
use std::util::swap;
|
||||
use std::vec;
|
||||
|
||||
|
@ -471,7 +470,7 @@ impl<T:Clone + Ord> MergeState<T> {
|
|||
assert!(len1 != 0 && len2 != 0 && base1+len1 == base2);
|
||||
|
||||
let mut tmp = ~[];
|
||||
for uint::range(base1, base1+len1) |i| {
|
||||
foreach i in range(base1, base1+len1) {
|
||||
tmp.push(array[i].clone());
|
||||
}
|
||||
|
||||
|
@ -581,7 +580,7 @@ impl<T:Clone + Ord> MergeState<T> {
|
|||
assert!(len1 != 1 && len2 != 0 && base1 + len1 == base2);
|
||||
|
||||
let mut tmp = ~[];
|
||||
for uint::range(base2, base2+len2) |i| {
|
||||
foreach i in range(base2, base2+len2) {
|
||||
tmp.push(array[i].clone());
|
||||
}
|
||||
|
||||
|
@ -1022,7 +1021,6 @@ mod big_tests {
|
|||
|
||||
use std::rand::RngUtil;
|
||||
use std::rand;
|
||||
use std::uint;
|
||||
use std::vec;
|
||||
|
||||
#[test]
|
||||
|
@ -1056,7 +1054,7 @@ mod big_tests {
|
|||
|
||||
fn tabulate_unique(lo: uint, hi: uint) {
|
||||
fn isSorted<T:Ord>(arr: &[T]) {
|
||||
for uint::range(0, arr.len()-1) |i| {
|
||||
foreach i in range(0u, arr.len() - 1) {
|
||||
if arr[i] > arr[i+1] {
|
||||
fail!("Array not sorted");
|
||||
}
|
||||
|
@ -1065,7 +1063,7 @@ mod big_tests {
|
|||
|
||||
let mut rng = rand::rng();
|
||||
|
||||
for uint::range(lo, hi) |i| {
|
||||
foreach i in range(lo, hi) {
|
||||
let n = 1 << i;
|
||||
let mut arr: ~[float] = do vec::from_fn(n) |_i| {
|
||||
rng.gen()
|
||||
|
@ -1127,7 +1125,7 @@ mod big_tests {
|
|||
|
||||
fn tabulate_managed(lo: uint, hi: uint) {
|
||||
fn isSorted<T:Ord>(arr: &[@T]) {
|
||||
for uint::range(0, arr.len()-1) |i| {
|
||||
foreach i in range(0u, arr.len() - 1) {
|
||||
if arr[i] > arr[i+1] {
|
||||
fail!("Array not sorted");
|
||||
}
|
||||
|
@ -1136,7 +1134,7 @@ mod big_tests {
|
|||
|
||||
let mut rng = rand::rng();
|
||||
|
||||
for uint::range(lo, hi) |i| {
|
||||
foreach i in range(lo, hi) {
|
||||
let n = 1 << i;
|
||||
let arr: ~[@float] = do vec::from_fn(n) |_i| {
|
||||
@rng.gen()
|
||||
|
|
|
@ -14,13 +14,12 @@
|
|||
use std::os;
|
||||
use std::rand::RngUtil;
|
||||
use std::rand;
|
||||
use std::uint;
|
||||
|
||||
/// Attempts to make a temporary directory inside of `tmpdir` whose name will
|
||||
/// have the suffix `suffix`. If no directory can be created, None is returned.
|
||||
pub fn mkdtemp(tmpdir: &Path, suffix: &str) -> Option<Path> {
|
||||
let mut r = rand::rng();
|
||||
for uint::range(0, 1000) |_| {
|
||||
foreach _ in range(0u, 1000) {
|
||||
let p = tmpdir.push(r.gen_str(16) + suffix);
|
||||
if os::make_dir(&p, 0x1c0) { // 700
|
||||
return Some(p);
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
/// ncurses-compatible compiled terminfo format parsing (term(5))
|
||||
|
||||
|
||||
use std::{vec, int, str};
|
||||
use std::{vec, str};
|
||||
use std::io::Reader;
|
||||
use std::hashmap::HashMap;
|
||||
use super::super::TermInfo;
|
||||
|
@ -222,7 +222,7 @@ pub fn parse(file: @Reader, longnames: bool) -> Result<~TermInfo, ~str> {
|
|||
|
||||
let mut bools_map = HashMap::new();
|
||||
if bools_bytes != 0 {
|
||||
for int::range(0, bools_bytes) |i| {
|
||||
foreach i in range(0, bools_bytes) {
|
||||
let b = file.read_byte();
|
||||
if b < 0 {
|
||||
error!("EOF reading bools after %? entries", i);
|
||||
|
@ -243,7 +243,7 @@ pub fn parse(file: @Reader, longnames: bool) -> Result<~TermInfo, ~str> {
|
|||
|
||||
let mut numbers_map = HashMap::new();
|
||||
if numbers_count != 0 {
|
||||
for int::range(0, numbers_count) |i| {
|
||||
foreach i in range(0, numbers_count) {
|
||||
let n = file.read_le_u16();
|
||||
if n != 0xFFFF {
|
||||
debug!("%s#%?", nnames[i], n);
|
||||
|
@ -258,7 +258,7 @@ pub fn parse(file: @Reader, longnames: bool) -> Result<~TermInfo, ~str> {
|
|||
|
||||
if string_offsets_count != 0 {
|
||||
let mut string_offsets = vec::with_capacity(10);
|
||||
for int::range(0, string_offsets_count) |_i| {
|
||||
foreach _ in range(0, string_offsets_count) {
|
||||
string_offsets.push(file.read_le_u16());
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,6 @@ use std::io;
|
|||
use std::result;
|
||||
use std::task;
|
||||
use std::to_str::ToStr;
|
||||
use std::u64;
|
||||
use std::f64;
|
||||
use std::os;
|
||||
|
||||
|
@ -991,7 +990,7 @@ impl BenchHarness {
|
|||
pub fn iter(&mut self, inner:&fn()) {
|
||||
self.ns_start = precise_time_ns();
|
||||
let k = self.iterations;
|
||||
for u64::range(0, k) |_| {
|
||||
foreach _ in range(0u64, k) {
|
||||
inner();
|
||||
}
|
||||
self.ns_end = precise_time_ns();
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
use std::num;
|
||||
use std::util::{swap, replace};
|
||||
use std::iterator::{FromIterator, Extendable};
|
||||
use std::uint;
|
||||
|
||||
// This is implemented as an AA tree, which is a simplified variation of
|
||||
// a red-black tree where red (horizontal) nodes can only be added
|
||||
|
@ -48,7 +47,7 @@ impl<K: Eq + TotalOrd, V: Eq> Eq for TreeMap<K, V> {
|
|||
} else {
|
||||
let mut x = self.iter();
|
||||
let mut y = other.iter();
|
||||
for uint::range(0, self.len()) |_| {
|
||||
foreach _ in range(0u, self.len()) {
|
||||
if x.next().unwrap() != y.next().unwrap() {
|
||||
return false
|
||||
}
|
||||
|
@ -66,7 +65,7 @@ fn lt<K: Ord + TotalOrd, V: Ord>(a: &TreeMap<K, V>,
|
|||
let mut y = b.iter();
|
||||
|
||||
let (a_len, b_len) = (a.len(), b.len());
|
||||
for uint::range(0, num::min(a_len, b_len)) |_| {
|
||||
foreach _ in range(0u, num::min(a_len, b_len)) {
|
||||
let (key_a, value_a) = x.next().unwrap();
|
||||
let (key_b, value_b) = y.next().unwrap();
|
||||
if *key_a < *key_b { return true; }
|
||||
|
|
|
@ -16,7 +16,6 @@ use metadata::filesearch;
|
|||
use std::hashmap::HashSet;
|
||||
use std::num;
|
||||
use std::os;
|
||||
use std::uint;
|
||||
use std::util;
|
||||
use std::vec;
|
||||
|
||||
|
@ -150,7 +149,7 @@ pub fn get_relative_to(abs1: &Path, abs2: &Path) -> Path {
|
|||
}
|
||||
|
||||
let mut path = ~[];
|
||||
for uint::range(start_idx, len1 - 1) |_i| { path.push(~".."); };
|
||||
foreach _ in range(start_idx, len1 - 1) { path.push(~".."); };
|
||||
|
||||
path.push_all(split2.slice(start_idx, len2 - 1));
|
||||
|
||||
|
|
|
@ -1256,7 +1256,7 @@ fn create_index<T:Clone + Hash + IterBytes + 'static>(
|
|||
index: ~[entry<T>])
|
||||
-> ~[@~[entry<T>]] {
|
||||
let mut buckets: ~[@mut ~[entry<T>]] = ~[];
|
||||
for uint::range(0u, 256u) |_i| { buckets.push(@mut ~[]); };
|
||||
foreach _ in range(0u, 256u) { buckets.push(@mut ~[]); };
|
||||
foreach elt in index.iter() {
|
||||
let h = elt.val.hash() as uint;
|
||||
buckets[h % 256].push((*elt).clone());
|
||||
|
|
|
@ -24,7 +24,6 @@ use middle;
|
|||
use util::ppaux::ty_to_str;
|
||||
|
||||
use std::at_vec;
|
||||
use std::uint;
|
||||
use extra::ebml::reader;
|
||||
use extra::ebml;
|
||||
use extra::serialize;
|
||||
|
@ -1055,7 +1054,7 @@ impl ebml_decoder_decoder_helpers for reader::Decoder {
|
|||
|
||||
fn type_string(doc: ebml::Doc) -> ~str {
|
||||
let mut str = ~"";
|
||||
for uint::range(doc.start, doc.end) |i| {
|
||||
foreach i in range(doc.start, doc.end) {
|
||||
str.push_char(doc.data[i] as char);
|
||||
}
|
||||
str
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
|
||||
use std::hashmap::HashSet;
|
||||
use std::uint;
|
||||
use mc = middle::mem_categorization;
|
||||
use middle::borrowck::*;
|
||||
use middle::moves;
|
||||
|
@ -158,9 +157,9 @@ impl<'self> CheckLoanCtxt<'self> {
|
|||
}
|
||||
}
|
||||
|
||||
for uint::range(0, new_loan_indices.len()) |i| {
|
||||
foreach i in range(0u, new_loan_indices.len()) {
|
||||
let old_loan = &self.all_loans[new_loan_indices[i]];
|
||||
for uint::range(i+1, new_loan_indices.len()) |j| {
|
||||
foreach j in range(i+1, new_loan_indices.len()) {
|
||||
let new_loan = &self.all_loans[new_loan_indices[j]];
|
||||
self.report_error_if_loans_conflict(old_loan, new_loan);
|
||||
}
|
||||
|
|
|
@ -18,8 +18,8 @@ use middle::typeck::method_map;
|
|||
use middle::moves;
|
||||
use util::ppaux::ty_to_str;
|
||||
|
||||
use std::iterator;
|
||||
use std::num;
|
||||
use std::uint;
|
||||
use std::vec;
|
||||
use extra::sort;
|
||||
use syntax::ast::*;
|
||||
|
@ -261,7 +261,7 @@ pub fn is_useful(cx: &MatchCheckCtxt, m: &matrix, v: &[@pat]) -> useful {
|
|||
_ => max_len
|
||||
}
|
||||
};
|
||||
for uint::range(0, max_len + 1) |n| {
|
||||
foreach n in iterator::range(0u, max_len + 1) {
|
||||
match is_useful_specialized(cx, m, v, vec(n), n, left_ty) {
|
||||
not_useful => (),
|
||||
ref u => return *u,
|
||||
|
|
|
@ -269,7 +269,7 @@ impl<O:DataFlowOperator> DataFlowContext<O> {
|
|||
foreach (word_index, &word) in words.iter().enumerate() {
|
||||
if word != 0 {
|
||||
let base_index = word_index * uint::bits;
|
||||
for uint::range(0, uint::bits) |offset| {
|
||||
foreach offset in range(0u, uint::bits) {
|
||||
let bit = 1 << offset;
|
||||
if (word & bit) != 0 {
|
||||
// NB: we round up the total number of bits
|
||||
|
@ -998,7 +998,7 @@ fn bits_to_str(words: &[uint]) -> ~str {
|
|||
|
||||
foreach &word in words.iter() {
|
||||
let mut v = word;
|
||||
for uint::range(0, uint::bytes) |_| {
|
||||
foreach _ in range(0u, uint::bytes) {
|
||||
result.push_char(sep);
|
||||
result.push_str(fmt!("%02x", v & 0xFF));
|
||||
v >>= 8;
|
||||
|
@ -1025,13 +1025,13 @@ fn bitwise(out_vec: &mut [uint],
|
|||
op: &fn(uint, uint) -> uint) -> bool {
|
||||
assert_eq!(out_vec.len(), in_vec.len());
|
||||
let mut changed = false;
|
||||
for uint::range(0, out_vec.len()) |i| {
|
||||
foreach i in range(0u, out_vec.len()) {
|
||||
let old_val = out_vec[i];
|
||||
let new_val = op(old_val, in_vec[i]);
|
||||
out_vec[i] = new_val;
|
||||
changed |= (old_val != new_val);
|
||||
}
|
||||
return changed;
|
||||
changed
|
||||
}
|
||||
|
||||
fn set_bit(words: &mut [uint], bit: uint) -> bool {
|
||||
|
|
|
@ -187,16 +187,12 @@ impl<N,E> Graph<N,E> {
|
|||
|
||||
pub fn each_node(&self, f: &fn(NodeIndex, &Node<N>) -> bool) -> bool {
|
||||
//! Iterates over all edges defined in the graph.
|
||||
|
||||
uint::range(0, self.nodes.len(),
|
||||
|i| f(NodeIndex(i), &self.nodes[i]))
|
||||
range(0u, self.nodes.len()).advance(|i| f(NodeIndex(i), &self.nodes[i]))
|
||||
}
|
||||
|
||||
pub fn each_edge(&self, f: &fn(EdgeIndex, &Edge<E>) -> bool) -> bool {
|
||||
//! Iterates over all edges defined in the graph.
|
||||
|
||||
uint::range(0, self.nodes.len(),
|
||||
|i| f(EdgeIndex(i), &self.edges[i]))
|
||||
range(0u, self.nodes.len()).advance(|i| f(EdgeIndex(i), &self.edges[i]))
|
||||
}
|
||||
|
||||
pub fn each_outgoing_edge(&self,
|
||||
|
|
|
@ -710,7 +710,7 @@ impl Liveness {
|
|||
|
||||
pub fn indices(&self, ln: LiveNode, op: &fn(uint)) {
|
||||
let node_base_idx = self.idx(ln, Variable(0));
|
||||
for uint::range(0, self.ir.num_vars) |var_idx| {
|
||||
foreach var_idx in range(0u, self.ir.num_vars) {
|
||||
op(node_base_idx + var_idx)
|
||||
}
|
||||
}
|
||||
|
@ -721,7 +721,7 @@ impl Liveness {
|
|||
op: &fn(uint, uint)) {
|
||||
let node_base_idx = self.idx(ln, Variable(0u));
|
||||
let succ_base_idx = self.idx(succ_ln, Variable(0u));
|
||||
for uint::range(0u, self.ir.num_vars) |var_idx| {
|
||||
foreach var_idx in range(0u, self.ir.num_vars) {
|
||||
op(node_base_idx + var_idx, succ_base_idx + var_idx);
|
||||
}
|
||||
}
|
||||
|
@ -731,7 +731,7 @@ impl Liveness {
|
|||
ln: LiveNode,
|
||||
test: &fn(uint) -> LiveNode) {
|
||||
let node_base_idx = self.idx(ln, Variable(0));
|
||||
for uint::range(0, self.ir.num_vars) |var_idx| {
|
||||
foreach var_idx in range(0u, self.ir.num_vars) {
|
||||
let idx = node_base_idx + var_idx;
|
||||
if test(idx).is_valid() {
|
||||
wr.write_str(" ");
|
||||
|
@ -900,7 +900,7 @@ impl Liveness {
|
|||
// hack to skip the loop unless debug! is enabled:
|
||||
debug!("^^ liveness computation results for body %d (entry=%s)",
|
||||
{
|
||||
for uint::range(0u, self.ir.num_live_nodes) |ln_idx| {
|
||||
foreach ln_idx in range(0u, self.ir.num_live_nodes) {
|
||||
debug!("%s", self.ln_str(LiveNode(ln_idx)));
|
||||
}
|
||||
body.id
|
||||
|
|
|
@ -52,7 +52,6 @@ use middle::typeck;
|
|||
use util::ppaux::{ty_to_str, region_ptr_to_str, Repr};
|
||||
use util::common::indenter;
|
||||
|
||||
use std::uint;
|
||||
use syntax::ast::{m_imm, m_const, m_mutbl};
|
||||
use syntax::ast;
|
||||
use syntax::codemap::span;
|
||||
|
@ -376,7 +375,7 @@ impl mem_categorization_ctxt {
|
|||
pub fn cat_expr_autoderefd(&self, expr: @ast::expr, autoderefs: uint)
|
||||
-> cmt {
|
||||
let mut cmt = self.cat_expr_unadjusted(expr);
|
||||
for uint::range(1, autoderefs+1) |deref| {
|
||||
foreach deref in range(1u, autoderefs + 1) {
|
||||
cmt = self.cat_deref(expr, cmt, deref);
|
||||
}
|
||||
return cmt;
|
||||
|
|
|
@ -1769,7 +1769,7 @@ pub fn copy_args_to_allocas(fcx: @mut FunctionContext,
|
|||
_ => {}
|
||||
}
|
||||
|
||||
for uint::range(0, arg_tys.len()) |arg_n| {
|
||||
foreach arg_n in range(0u, arg_tys.len()) {
|
||||
let arg_ty = arg_tys[arg_n];
|
||||
let raw_llarg = raw_llargs[arg_n];
|
||||
|
||||
|
@ -1965,7 +1965,7 @@ fn insert_synthetic_type_entries(bcx: @mut Block,
|
|||
*/
|
||||
|
||||
let tcx = bcx.tcx();
|
||||
for uint::range(0, fn_args.len()) |i| {
|
||||
foreach i in range(0u, fn_args.len()) {
|
||||
debug!("setting type of argument %u (pat node %d) to %s",
|
||||
i, fn_args[i].pat.id, bcx.ty_to_str(arg_tys[i]));
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@ use middle::trans::type_::Type;
|
|||
use std::num;
|
||||
use std::option;
|
||||
use std::option::Option;
|
||||
use std::uint;
|
||||
use std::vec;
|
||||
|
||||
#[deriving(Clone, Eq)]
|
||||
|
@ -146,7 +145,7 @@ fn classify_ty(ty: Type) -> ~[RegClass] {
|
|||
}
|
||||
|
||||
fn all_mem(cls: &mut [RegClass]) {
|
||||
for uint::range(0, cls.len()) |i| {
|
||||
foreach i in range(0u, cls.len()) {
|
||||
cls[i] = Memory;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,6 @@ use middle::ty::FnSig;
|
|||
use util::ppaux::ty_to_str;
|
||||
|
||||
use std::cell::Cell;
|
||||
use std::uint;
|
||||
use std::vec;
|
||||
use syntax::codemap::span;
|
||||
use syntax::{ast, ast_util};
|
||||
|
@ -499,7 +498,7 @@ pub fn trans_foreign_mod(ccx: @mut CrateContext,
|
|||
let _icx = push_ctxt("foreign::wrap::build_args");
|
||||
let ccx = bcx.ccx();
|
||||
let n = tys.llsig.llarg_tys.len();
|
||||
for uint::range(0, n) |i| {
|
||||
foreach i in range(0u, n) {
|
||||
let arg_i = bcx.fcx.arg_pos(i);
|
||||
let mut llargval = get_param(llwrapfn, arg_i);
|
||||
|
||||
|
@ -544,7 +543,7 @@ pub fn trans_intrinsic(ccx: @mut CrateContext,
|
|||
assert!(num_args <= 4);
|
||||
let mut args = [0 as ValueRef, ..4];
|
||||
let first_real_arg = bcx.fcx.arg_pos(0u);
|
||||
for uint::range(0, num_args) |i| {
|
||||
foreach i in range(0u, num_args) {
|
||||
args[i] = get_param(bcx.fcx.llfn, first_real_arg + i);
|
||||
}
|
||||
let llfn = bcx.ccx().intrinsics.get_copy(&name);
|
||||
|
|
|
@ -34,7 +34,6 @@ use middle::ty;
|
|||
use middle::typeck;
|
||||
|
||||
use std::option::{Some, None};
|
||||
use std::uint;
|
||||
use std::vec;
|
||||
use extra::list::{List, Cons, Nil};
|
||||
use extra::list;
|
||||
|
@ -94,7 +93,7 @@ pub fn type_uses_for(ccx: @mut CrateContext, fn_id: def_id, n_tps: uint)
|
|||
// We also mark all of the params as used if it is an extern thing
|
||||
// that we haven't been able to inline yet.
|
||||
if is_default || fn_id_loc.crate != LOCAL_CRATE {
|
||||
for uint::range(0u, n_tps) |n| { cx.uses[n] |= use_all; }
|
||||
foreach n in range(0u, n_tps) { cx.uses[n] |= use_all; }
|
||||
return store_type_uses(cx, fn_id);
|
||||
}
|
||||
|
||||
|
@ -118,13 +117,13 @@ pub fn type_uses_for(ccx: @mut CrateContext, fn_id: def_id, n_tps: uint)
|
|||
// This will be a static trait method. For now, we just assume
|
||||
// it fully depends on all of the type information. (Doing
|
||||
// otherwise would require finding the actual implementation).
|
||||
for uint::range(0u, n_tps) |n| { cx.uses[n] |= use_all;}
|
||||
foreach n in range(0u, n_tps) { cx.uses[n] |= use_all;}
|
||||
// We need to return early, before the arguments are processed,
|
||||
// because of difficulties in the handling of Self.
|
||||
return store_type_uses(cx, fn_id);
|
||||
}
|
||||
ast_map::node_variant(_, _, _) => {
|
||||
for uint::range(0u, n_tps) |n| { cx.uses[n] |= use_repr;}
|
||||
foreach n in range(0u, n_tps) { cx.uses[n] |= use_repr;}
|
||||
}
|
||||
ast_map::node_foreign_item(i@@foreign_item {
|
||||
node: foreign_item_fn(*),
|
||||
|
@ -173,13 +172,13 @@ pub fn type_uses_for(ccx: @mut CrateContext, fn_id: def_id, n_tps: uint)
|
|||
_ => fail!("unknown intrinsic in type_use")
|
||||
}
|
||||
};
|
||||
for uint::range(0u, n_tps) |n| { cx.uses[n] |= flags;}
|
||||
foreach n in range(0u, n_tps) { cx.uses[n] |= flags;}
|
||||
}
|
||||
}
|
||||
ast_map::node_struct_ctor(*) => {
|
||||
// Similarly to node_variant, this monomorphized function just
|
||||
// uses the representations of all of its type parameters.
|
||||
for uint::range(0, n_tps) |n| { cx.uses[n] |= use_repr; }
|
||||
foreach n in range(0u, n_tps) { cx.uses[n] |= use_repr; }
|
||||
}
|
||||
_ => {
|
||||
ccx.tcx.sess.bug(fmt!("unknown node type in type_use: %s",
|
||||
|
@ -210,7 +209,7 @@ pub fn type_needs(cx: &Context, use_: uint, ty: ty::t) {
|
|||
let uses = &*cx.uses;
|
||||
uses.len()
|
||||
};
|
||||
for uint::range(0, len) |i| {
|
||||
foreach i in range(0u, len) {
|
||||
if cx.uses[i] & use_ != use_ {
|
||||
type_needs_inner(cx, use_, ty, @Nil);
|
||||
return;
|
||||
|
|
|
@ -34,7 +34,6 @@ use std::ops;
|
|||
use std::ptr::to_unsafe_ptr;
|
||||
use std::to_bytes;
|
||||
use std::u32;
|
||||
use std::uint;
|
||||
use std::vec;
|
||||
use syntax::ast::*;
|
||||
use syntax::ast_util::is_local;
|
||||
|
@ -2962,7 +2961,7 @@ pub fn adjust_ty(cx: ctxt,
|
|||
let mut adjusted_ty = unadjusted_ty;
|
||||
|
||||
if (!ty::type_is_error(adjusted_ty)) {
|
||||
for uint::range(0, adj.autoderefs) |i| {
|
||||
foreach i in range(0, adj.autoderefs) {
|
||||
match ty::deref(cx, adjusted_ty, true) {
|
||||
Some(mt) => { adjusted_ty = mt.ty; }
|
||||
None => {
|
||||
|
|
|
@ -97,7 +97,6 @@ use util::common::indenter;
|
|||
|
||||
use std::hashmap::HashSet;
|
||||
use std::result;
|
||||
use std::uint;
|
||||
use std::vec;
|
||||
use extra::list::Nil;
|
||||
use syntax::ast::{def_id, sty_value, sty_region, sty_box};
|
||||
|
@ -775,7 +774,7 @@ impl<'self> LookupContext<'self> {
|
|||
self.tcx().sess.span_err(
|
||||
self.expr.span,
|
||||
"multiple applicable methods in scope");
|
||||
for uint::range(0, relevant_candidates.len()) |idx| {
|
||||
foreach idx in range(0u, relevant_candidates.len()) {
|
||||
self.report_candidate(idx, &relevant_candidates[idx].origin);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,6 @@ use middle::typeck::infer;
|
|||
use util::ppaux::{ty_to_str, region_to_str};
|
||||
use middle::pat_util;
|
||||
|
||||
use std::uint;
|
||||
use syntax::ast::{ManagedSigil, OwnedSigil, BorrowedSigil};
|
||||
use syntax::ast::{def_arg, def_binding, def_local, def_self, def_upvar};
|
||||
use syntax::ast;
|
||||
|
@ -600,7 +599,7 @@ fn constrain_derefs(rcx: @mut Rcx,
|
|||
*/
|
||||
let tcx = rcx.fcx.tcx();
|
||||
let r_deref_expr = ty::re_scope(deref_expr.id);
|
||||
for uint::range(0, derefs) |i| {
|
||||
foreach i in range(0u, derefs) {
|
||||
debug!("constrain_derefs(deref_expr=?, derefd_ty=%s, derefs=%?/%?",
|
||||
rcx.fcx.infcx().ty_to_str(derefd_ty),
|
||||
i, derefs);
|
||||
|
@ -810,8 +809,6 @@ pub mod guarantor {
|
|||
use syntax::codemap::span;
|
||||
use util::ppaux::{ty_to_str};
|
||||
|
||||
use std::uint;
|
||||
|
||||
pub fn for_addr_of(rcx: @mut Rcx, expr: @ast::expr, base: @ast::expr) {
|
||||
/*!
|
||||
* Computes the guarantor for an expression `&base` and then
|
||||
|
@ -1132,7 +1129,7 @@ pub mod guarantor {
|
|||
return ct;
|
||||
}
|
||||
|
||||
for uint::range(0, autoderefs) |_| {
|
||||
foreach _ in range(0u, autoderefs) {
|
||||
ct.cat.guarantor = guarantor_of_deref(&ct.cat);
|
||||
|
||||
match ty::deref(tcx, ct.ty, true) {
|
||||
|
|
|
@ -54,7 +54,6 @@ use util::ppaux::ty_to_str;
|
|||
|
||||
use std::hashmap::{HashMap, HashSet};
|
||||
use std::result::Ok;
|
||||
use std::uint;
|
||||
use std::vec;
|
||||
|
||||
pub struct UniversalQuantificationResult {
|
||||
|
@ -551,7 +550,7 @@ impl CoherenceChecker {
|
|||
|
||||
let mut provided_names = HashSet::new();
|
||||
// Implemented methods
|
||||
for uint::range(0, all_methods.len()) |i| {
|
||||
foreach i in range(0u, all_methods.len()) {
|
||||
provided_names.insert(all_methods[i].ident);
|
||||
}
|
||||
|
||||
|
|
|
@ -374,7 +374,7 @@ impl RegionVarBindings {
|
|||
pub fn vars_created_since_snapshot(&mut self, snapshot: uint)
|
||||
-> ~[RegionVid] {
|
||||
do vec::build |push| {
|
||||
for uint::range(snapshot, self.undo_log.len()) |i| {
|
||||
foreach i in range(snapshot, self.undo_log.len()) {
|
||||
match self.undo_log[i] {
|
||||
AddVar(vid) => push(vid),
|
||||
_ => ()
|
||||
|
@ -962,7 +962,7 @@ impl RegionVarBindings {
|
|||
|
||||
let mut opt_graph = None;
|
||||
|
||||
for uint::range(0, self.num_vars()) |idx| {
|
||||
foreach idx in range(0u, self.num_vars()) {
|
||||
match var_data[idx].value {
|
||||
Value(_) => {
|
||||
/* Inference successful */
|
||||
|
@ -1027,7 +1027,7 @@ impl RegionVarBindings {
|
|||
let mut graph = graph::Graph::with_capacity(num_vars + 1,
|
||||
num_edges);
|
||||
|
||||
for uint::range(0, num_vars) |_| {
|
||||
foreach _ in range(0u, num_vars) {
|
||||
graph.add_node(());
|
||||
}
|
||||
let dummy_idx = graph.add_node(());
|
||||
|
|
|
@ -12,10 +12,9 @@
|
|||
|
||||
use clone::Clone;
|
||||
use container::Container;
|
||||
use iterator::Iterator;
|
||||
use iterator::{Iterator, range};
|
||||
use option::{Option, Some, None};
|
||||
use sys;
|
||||
use uint;
|
||||
use unstable::raw::Repr;
|
||||
use vec::{ImmutableVector, OwnedVector};
|
||||
|
||||
|
@ -95,7 +94,7 @@ pub fn append<T:Clone>(lhs: @[T], rhs: &[T]) -> @[T] {
|
|||
foreach x in lhs.iter() {
|
||||
push((*x).clone());
|
||||
}
|
||||
for uint::range(0, rhs.len()) |i| {
|
||||
foreach i in range(0u, rhs.len()) {
|
||||
push(rhs[i].clone());
|
||||
}
|
||||
}
|
||||
|
@ -323,14 +322,14 @@ pub mod raw {
|
|||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use uint;
|
||||
use prelude::*;
|
||||
|
||||
#[test]
|
||||
fn test() {
|
||||
// Some code that could use that, then:
|
||||
fn seq_range(lo: uint, hi: uint) -> @[uint] {
|
||||
do build |push| {
|
||||
for uint::range(lo, hi) |i| {
|
||||
foreach i in range(lo, hi) {
|
||||
push(i);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ use container::{Container, Mutable, Map, MutableMap, Set, MutableSet};
|
|||
use clone::Clone;
|
||||
use cmp::{Eq, Equiv};
|
||||
use hash::Hash;
|
||||
use iterator::{Iterator, IteratorUtil, FromIterator, Extendable, Chain};
|
||||
use iterator::{Iterator, IteratorUtil, FromIterator, Extendable, Chain, range};
|
||||
use num;
|
||||
use option::{None, Option, Some};
|
||||
use rand::RngUtil;
|
||||
|
@ -284,7 +284,7 @@ impl<K:Hash + Eq,V> Container for HashMap<K, V> {
|
|||
impl<K:Hash + Eq,V> Mutable for HashMap<K, V> {
|
||||
/// Clear the map, removing all key-value pairs.
|
||||
fn clear(&mut self) {
|
||||
for uint::range(0, self.buckets.len()) |idx| {
|
||||
foreach idx in range(0u, self.buckets.len()) {
|
||||
self.buckets[idx] = None;
|
||||
}
|
||||
self.size = 0;
|
||||
|
@ -802,10 +802,8 @@ pub type SetAlgebraIter<'self, T> =
|
|||
|
||||
#[cfg(test)]
|
||||
mod test_map {
|
||||
use container::{Container, Map};
|
||||
use option::{None, Some};
|
||||
use prelude::*;
|
||||
use super::*;
|
||||
use uint;
|
||||
|
||||
#[test]
|
||||
fn test_create_capacity_zero() {
|
||||
|
@ -930,7 +928,7 @@ mod test_map {
|
|||
#[test]
|
||||
fn test_iterate() {
|
||||
let mut m = linear_map_with_capacity(4);
|
||||
for uint::range(0, 32) |i| {
|
||||
foreach i in range(0u, 32) {
|
||||
assert!(m.insert(i, i*2));
|
||||
}
|
||||
let mut observed = 0;
|
||||
|
@ -1023,7 +1021,6 @@ mod test_set {
|
|||
use prelude::*;
|
||||
use container::Container;
|
||||
use vec::ImmutableEqVector;
|
||||
use uint;
|
||||
|
||||
#[test]
|
||||
fn test_disjoint() {
|
||||
|
@ -1079,7 +1076,7 @@ mod test_set {
|
|||
#[test]
|
||||
fn test_iterate() {
|
||||
let mut a = HashSet::new();
|
||||
for uint::range(0, 32) |i| {
|
||||
foreach i in range(0u, 32) {
|
||||
assert!(a.insert(i));
|
||||
}
|
||||
let mut observed = 0;
|
||||
|
|
|
@ -47,6 +47,7 @@ pub trait Iterator<A> {
|
|||
/// Return a lower bound and upper bound on the remaining length of the iterator.
|
||||
///
|
||||
/// The common use case for the estimate is pre-allocating space to store the results.
|
||||
#[inline]
|
||||
fn size_hint(&self) -> (uint, Option<uint>) { (0, None) }
|
||||
}
|
||||
|
||||
|
@ -1513,11 +1514,38 @@ impl<A> Counter<A> {
|
|||
}
|
||||
}
|
||||
|
||||
/// A range of numbers from [0, N)
|
||||
#[deriving(Clone, DeepClone)]
|
||||
pub struct Range<A> {
|
||||
priv state: A,
|
||||
priv stop: A,
|
||||
priv one: A
|
||||
}
|
||||
|
||||
/// Return an iterator over the range [start, stop)
|
||||
#[inline]
|
||||
pub fn range<A: Add<A, A> + Ord + Clone + One>(start: A, stop: A) -> Range<A> {
|
||||
Range{state: start, stop: stop, one: One::one()}
|
||||
}
|
||||
|
||||
impl<A: Add<A, A> + Ord + Clone + One> Iterator<A> for Range<A> {
|
||||
#[inline]
|
||||
fn next(&mut self) -> Option<A> {
|
||||
if self.state < self.stop {
|
||||
let result = self.state.clone();
|
||||
self.state = self.state + self.one;
|
||||
Some(result)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<A: Add<A, A> + Clone> Iterator<A> for Counter<A> {
|
||||
#[inline]
|
||||
fn next(&mut self) -> Option<A> {
|
||||
let result = self.state.clone();
|
||||
self.state = self.state.add(&self.step); // FIXME: #6050
|
||||
self.state = self.state + self.step;
|
||||
Some(result)
|
||||
}
|
||||
|
||||
|
@ -1717,7 +1745,7 @@ mod tests {
|
|||
#[test]
|
||||
fn test_iterator_nth() {
|
||||
let v = &[0, 1, 2, 3, 4];
|
||||
for uint::range(0, v.len()) |i| {
|
||||
foreach i in range(0u, v.len()) {
|
||||
assert_eq!(v.iter().nth(i).unwrap(), &v[i]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -125,12 +125,6 @@ pub fn range_step_inclusive(start: $T, last: $T, step: $T, it: &fn($T) -> bool)
|
|||
}
|
||||
|
||||
|
||||
#[inline]
|
||||
/// Iterate over the range [`lo`..`hi`)
|
||||
pub fn range(lo: $T, hi: $T, it: &fn($T) -> bool) -> bool {
|
||||
range_step(lo, hi, 1 as $T, it)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
/// Iterate over the range (`hi`..`lo`]
|
||||
pub fn range_rev(hi: $T, lo: $T, it: &fn($T) -> bool) -> bool {
|
||||
|
@ -895,9 +889,6 @@ mod tests {
|
|||
fn test_ranges() {
|
||||
let mut l = ~[];
|
||||
|
||||
for range(0,3) |i| {
|
||||
l.push(i);
|
||||
}
|
||||
for range_rev(14,11) |i| {
|
||||
l.push(i);
|
||||
}
|
||||
|
@ -919,8 +910,7 @@ mod tests {
|
|||
for range_step(min_value + 3, min_value, -2) |i| {
|
||||
l.push(i);
|
||||
}
|
||||
assert_eq!(l, ~[0,1,2,
|
||||
13,12,11,
|
||||
assert_eq!(l, ~[13,12,11,
|
||||
20,22,24,
|
||||
36,34,32,
|
||||
max_value-2,
|
||||
|
@ -929,9 +919,6 @@ mod tests {
|
|||
min_value+3,min_value+1]);
|
||||
|
||||
// None of the `fail`s should execute.
|
||||
for range(10,0) |_i| {
|
||||
fail!(~"unreachable");
|
||||
}
|
||||
for range_rev(0,10) |_i| {
|
||||
fail!(~"unreachable");
|
||||
}
|
||||
|
|
|
@ -125,12 +125,6 @@ pub fn range_step_inclusive(start: $T, last: $T, step: $T_SIGNED, it: &fn($T) ->
|
|||
range_step_core(start, last, step, Closed, it)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
/// Iterate over the range [`lo`..`hi`)
|
||||
pub fn range(lo: $T, hi: $T, it: &fn($T) -> bool) -> bool {
|
||||
range_step(lo, hi, 1 as $T_SIGNED, it)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
/// Iterate over the range (`hi`..`lo`]
|
||||
pub fn range_rev(hi: $T, lo: $T, it: &fn($T) -> bool) -> bool {
|
||||
|
@ -660,9 +654,6 @@ mod tests {
|
|||
pub fn test_ranges() {
|
||||
let mut l = ~[];
|
||||
|
||||
for range(0,3) |i| {
|
||||
l.push(i);
|
||||
}
|
||||
for range_rev(14,11) |i| {
|
||||
l.push(i);
|
||||
}
|
||||
|
@ -685,8 +676,7 @@ mod tests {
|
|||
l.push(i);
|
||||
}
|
||||
|
||||
assert_eq!(l, ~[0,1,2,
|
||||
13,12,11,
|
||||
assert_eq!(l, ~[13,12,11,
|
||||
20,22,24,
|
||||
36,34,32,
|
||||
max_value-2,
|
||||
|
@ -695,9 +685,6 @@ mod tests {
|
|||
min_value+3,min_value+1]);
|
||||
|
||||
// None of the `fail`s should execute.
|
||||
for range(0,0) |_i| {
|
||||
fail!("unreachable");
|
||||
}
|
||||
for range_rev(0,0) |_i| {
|
||||
fail!("unreachable");
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ use cast;
|
|||
use clone::Clone;
|
||||
use container::Container;
|
||||
use io;
|
||||
use iterator::IteratorUtil;
|
||||
use iterator::{IteratorUtil, range};
|
||||
use libc;
|
||||
use libc::{c_char, c_void, c_int, size_t};
|
||||
use libc::FILE;
|
||||
|
@ -43,7 +43,6 @@ use prelude::*;
|
|||
use ptr;
|
||||
use str;
|
||||
use to_str;
|
||||
use uint;
|
||||
use unstable::finally::Finally;
|
||||
use vec;
|
||||
|
||||
|
@ -1114,7 +1113,7 @@ pub fn set_exit_status(code: int) {
|
|||
|
||||
unsafe fn load_argc_and_argv(argc: c_int, argv: **c_char) -> ~[~str] {
|
||||
let mut args = ~[];
|
||||
for uint::range(0, argc as uint) |i| {
|
||||
foreach i in range(0u, argc as uint) {
|
||||
args.push(str::raw::from_c_str(*argv.offset(i as int)));
|
||||
}
|
||||
args
|
||||
|
@ -1163,7 +1162,7 @@ pub fn real_args() -> ~[~str] {
|
|||
let szArgList = unsafe { CommandLineToArgvW(lpCmdLine, lpArgCount) };
|
||||
|
||||
let mut args = ~[];
|
||||
for uint::range(0, nArgs as uint) |i| {
|
||||
foreach i in range(0u, nArgs as uint) {
|
||||
unsafe {
|
||||
// Determine the length of this argument.
|
||||
let ptr = *szArgList.offset(i as int);
|
||||
|
|
|
@ -40,6 +40,7 @@ pub use result::{Result, Ok, Err};
|
|||
|
||||
// Reexported functions
|
||||
pub use io::{print, println};
|
||||
pub use iterator::range;
|
||||
|
||||
// Reexported types and traits
|
||||
pub use clone::{Clone, DeepClone};
|
||||
|
@ -49,7 +50,7 @@ pub use container::{Container, Mutable, Map, MutableMap, Set, MutableSet};
|
|||
pub use hash::Hash;
|
||||
pub use iter::Times;
|
||||
pub use iterator::{Iterator, IteratorUtil, DoubleEndedIterator, DoubleEndedIteratorUtil};
|
||||
pub use iterator::OrdIterator;
|
||||
pub use iterator::{ClonableIterator, OrdIterator};
|
||||
pub use num::{Num, NumCast};
|
||||
pub use num::{Orderable, Signed, Unsigned, Round};
|
||||
pub use num::{Algebraic, Trigonometric, Exponential, Hyperbolic};
|
||||
|
|
|
@ -48,6 +48,7 @@ use clone::Clone;
|
|||
use cmp;
|
||||
use container::Container;
|
||||
use int;
|
||||
use iterator::{Iterator, range};
|
||||
use local_data;
|
||||
use num;
|
||||
use prelude::*;
|
||||
|
@ -582,7 +583,7 @@ impl<R: Rng> RngUtil for R {
|
|||
fn weighted_vec<T:Clone>(&mut self, v: &[Weighted<T>]) -> ~[T] {
|
||||
let mut r = ~[];
|
||||
foreach item in v.iter() {
|
||||
for uint::range(0u, item.weight) |_i| {
|
||||
foreach _ in range(0u, item.weight) {
|
||||
r.push(item.item.clone());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,11 +53,10 @@ pub fn clone() -> Option<~[~str]> {
|
|||
#[cfg(target_os = "android")]
|
||||
#[cfg(target_os = "freebsd")]
|
||||
mod imp {
|
||||
|
||||
use libc;
|
||||
use option::{Option, Some, None};
|
||||
use iterator::{Iterator, range};
|
||||
use str;
|
||||
use uint;
|
||||
use unstable::finally::Finally;
|
||||
use util;
|
||||
|
||||
|
@ -113,10 +112,10 @@ mod imp {
|
|||
// Copied from `os`.
|
||||
unsafe fn load_argc_and_argv(argc: int, argv: **u8) -> ~[~str] {
|
||||
let mut args = ~[];
|
||||
for uint::range(0, argc as uint) |i| {
|
||||
foreach i in range(0u, argc as uint) {
|
||||
args.push(str::raw::from_c_str(*(argv as **libc::c_char).offset(i as int)));
|
||||
}
|
||||
return args;
|
||||
args
|
||||
}
|
||||
|
||||
extern {
|
||||
|
|
|
@ -143,11 +143,11 @@ impl Listener<TcpStream> for TcpListener {
|
|||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use int;
|
||||
use cell::Cell;
|
||||
use rt::test::*;
|
||||
use rt::io::net::ip::Ipv4;
|
||||
use rt::io::*;
|
||||
use prelude::*;
|
||||
|
||||
#[test] #[ignore]
|
||||
fn bind_error() {
|
||||
|
@ -421,7 +421,7 @@ mod test {
|
|||
|
||||
do spawntask {
|
||||
let mut listener = TcpListener::bind(addr);
|
||||
for int::range(0, MAX) |i| {
|
||||
foreach i in range(0, MAX) {
|
||||
let stream = Cell::new(listener.accept());
|
||||
rtdebug!("accepted");
|
||||
// Start another task to handle the connection
|
||||
|
@ -460,7 +460,7 @@ mod test {
|
|||
|
||||
do spawntask {
|
||||
let mut listener = TcpListener::bind(addr);
|
||||
for int::range(0, MAX) |i| {
|
||||
foreach i in range(0, MAX) {
|
||||
let stream = Cell::new(listener.accept());
|
||||
rtdebug!("accepted");
|
||||
// Start another task to handle the connection
|
||||
|
@ -499,7 +499,7 @@ mod test {
|
|||
|
||||
do spawntask {
|
||||
let mut listener = TcpListener::bind(addr);
|
||||
for int::range(0, MAX) |_| {
|
||||
foreach _ in range(0, MAX) {
|
||||
let stream = Cell::new(listener.accept());
|
||||
rtdebug!("accepted");
|
||||
// Start another task to handle the connection
|
||||
|
@ -537,7 +537,7 @@ mod test {
|
|||
|
||||
do spawntask {
|
||||
let mut listener = TcpListener::bind(addr);
|
||||
for int::range(0, MAX) |_| {
|
||||
foreach _ in range(0, MAX) {
|
||||
let stream = Cell::new(listener.accept());
|
||||
rtdebug!("accepted");
|
||||
// Start another task to handle the connection
|
||||
|
|
|
@ -723,13 +723,12 @@ impl ClosureConverter for UnsafeTaskReceiver {
|
|||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use prelude::*;
|
||||
use rt::test::*;
|
||||
use unstable::run_in_bare_thread;
|
||||
use borrow::to_uint;
|
||||
use rt::local::*;
|
||||
use rt::sched::{Scheduler};
|
||||
use uint;
|
||||
use int;
|
||||
use cell::Cell;
|
||||
use rt::thread::Thread;
|
||||
use rt::task::{Task, Sched};
|
||||
|
@ -752,7 +751,7 @@ mod test {
|
|||
let mut task_run_count = 0;
|
||||
let task_run_count_ptr: *mut uint = &mut task_run_count;
|
||||
do run_in_newsched_task || {
|
||||
for uint::range(0,total) |_| {
|
||||
foreach _ in range(0u, total) {
|
||||
do spawntask || {
|
||||
unsafe { *task_run_count_ptr = *task_run_count_ptr + 1};
|
||||
}
|
||||
|
@ -951,7 +950,7 @@ mod test {
|
|||
#[test]
|
||||
fn test_stress_schedule_task_states() {
|
||||
let n = stress_factor() * 120;
|
||||
for int::range(0,n as int) |_| {
|
||||
foreach _ in range(0, n as int) {
|
||||
test_schedule_home_states();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -111,6 +111,7 @@ mod test {
|
|||
use comm::GenericChan;
|
||||
use task;
|
||||
use cell::Cell;
|
||||
use iterator::{Iterator, range};
|
||||
|
||||
#[test] #[ignore(cfg(windows))] #[should_fail]
|
||||
fn select_doesnt_get_trolled() {
|
||||
|
@ -263,7 +264,6 @@ mod test {
|
|||
select_racing_senders_helper(false, ~[7,8,9]);
|
||||
|
||||
fn select_racing_senders_helper(killable: bool, send_on_chans: ~[uint]) {
|
||||
use uint;
|
||||
use rt::test::spawntask_random;
|
||||
|
||||
do run_in_newsched_task {
|
||||
|
@ -272,7 +272,7 @@ mod test {
|
|||
let send_on_chans = send_on_chans.clone();
|
||||
do task::spawn {
|
||||
let mut ports = ~[];
|
||||
for uint::range(0, NUM_CHANS) |i| {
|
||||
foreach i in range(0u, NUM_CHANS) {
|
||||
let (p,c) = oneshot();
|
||||
ports.push(p);
|
||||
if send_on_chans.contains(&i) {
|
||||
|
|
|
@ -14,7 +14,7 @@ use option::{Some, None};
|
|||
use cell::Cell;
|
||||
use clone::Clone;
|
||||
use container::Container;
|
||||
use iterator::Iterator;
|
||||
use iterator::{Iterator, range};
|
||||
use vec::{OwnedVector, MutableVector};
|
||||
use super::io::net::ip::{IpAddr, Ipv4, Ipv6};
|
||||
use rt::sched::Scheduler;
|
||||
|
@ -90,7 +90,7 @@ pub fn run_in_mt_newsched_task(f: ~fn()) {
|
|||
let mut handles = ~[];
|
||||
let mut scheds = ~[];
|
||||
|
||||
for uint::range(0, nthreads) |_| {
|
||||
foreach _ in range(0u, nthreads) {
|
||||
let loop_ = ~UvEventLoop::new();
|
||||
let mut sched = ~Scheduler::new(loop_,
|
||||
work_queue.clone(),
|
||||
|
|
|
@ -88,13 +88,13 @@ impl<T> Clone for Tube<T> {
|
|||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use int;
|
||||
use cell::Cell;
|
||||
use rt::test::*;
|
||||
use rt::rtio::EventLoop;
|
||||
use rt::sched::Scheduler;
|
||||
use rt::local::Local;
|
||||
use super::*;
|
||||
use prelude::*;
|
||||
|
||||
#[test]
|
||||
fn simple_test() {
|
||||
|
@ -166,7 +166,7 @@ mod test {
|
|||
sched.enqueue_blocked_task(task);
|
||||
}
|
||||
|
||||
for int::range(0, MAX) |i| {
|
||||
foreach i in range(0, MAX) {
|
||||
let j = tube.recv();
|
||||
assert!(j == i);
|
||||
}
|
||||
|
|
|
@ -31,11 +31,11 @@ use str::StrSlice;
|
|||
use unstable::sync::Exclusive;
|
||||
|
||||
#[cfg(test)] use container::Container;
|
||||
#[cfg(test)] use uint;
|
||||
#[cfg(test)] use unstable::run_in_bare_thread;
|
||||
#[cfg(test)] use rt::test::{spawntask,
|
||||
next_test_ip4,
|
||||
run_in_newsched_task};
|
||||
#[cfg(test)] use iterator::{Iterator, range};
|
||||
|
||||
enum SocketNameKind {
|
||||
TcpPeer,
|
||||
|
@ -843,7 +843,7 @@ fn test_simple_tcp_server_and_client() {
|
|||
let mut buf = [0, .. 2048];
|
||||
let nread = stream.read(buf).unwrap();
|
||||
assert_eq!(nread, 8);
|
||||
for uint::range(0, nread) |i| {
|
||||
foreach i in range(0u, nread) {
|
||||
rtdebug!("%u", buf[i] as uint);
|
||||
assert_eq!(buf[i], i as u8);
|
||||
}
|
||||
|
@ -873,7 +873,7 @@ fn test_simple_udp_server_and_client() {
|
|||
let mut buf = [0, .. 2048];
|
||||
let (nread,src) = server_socket.recvfrom(buf).unwrap();
|
||||
assert_eq!(nread, 8);
|
||||
for uint::range(0, nread) |i| {
|
||||
foreach i in range(0u, nread) {
|
||||
rtdebug!("%u", buf[i] as uint);
|
||||
assert_eq!(buf[i], i as u8);
|
||||
}
|
||||
|
@ -908,7 +908,7 @@ fn test_read_and_block() {
|
|||
|
||||
while current < expected {
|
||||
let nread = stream.read(buf).unwrap();
|
||||
for uint::range(0, nread) |i| {
|
||||
foreach i in range(0u, nread) {
|
||||
let val = buf[i] as uint;
|
||||
assert_eq!(val, current % 8);
|
||||
current += 1;
|
||||
|
@ -973,7 +973,7 @@ fn test_read_read_read() {
|
|||
let nread = stream.read(buf).unwrap();
|
||||
rtdebug!("read %u bytes", nread as uint);
|
||||
total_bytes_read += nread;
|
||||
for uint::range(0, nread) |i| {
|
||||
foreach i in range(0u, nread) {
|
||||
assert_eq!(buf[i], 1);
|
||||
}
|
||||
}
|
||||
|
@ -1065,7 +1065,7 @@ fn test_udp_many_read() {
|
|||
let (nread, src) = res.unwrap();
|
||||
assert_eq!(src, server_out_addr);
|
||||
total_bytes_recv += nread;
|
||||
for uint::range(0, nread) |i| {
|
||||
foreach i in range(0u, nread) {
|
||||
assert_eq!(buf[i], 1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -574,9 +574,6 @@ fn zeroed_process_information() -> libc::types::os::arch::extra::PROCESS_INFORMA
|
|||
// FIXME: this is only pub so it can be tested (see issue #4536)
|
||||
#[cfg(windows)]
|
||||
pub fn make_command_line(prog: &str, args: &[~str]) -> ~str {
|
||||
|
||||
use uint;
|
||||
|
||||
let mut cmd = ~"";
|
||||
append_arg(&mut cmd, prog);
|
||||
foreach arg in args.iter() {
|
||||
|
@ -590,7 +587,7 @@ pub fn make_command_line(prog: &str, args: &[~str]) -> ~str {
|
|||
if quote {
|
||||
cmd.push_char('"');
|
||||
}
|
||||
for uint::range(0, arg.len()) |i| {
|
||||
foreach i in range(0u, arg.len()) {
|
||||
append_char_at(cmd, arg, i);
|
||||
}
|
||||
if quote {
|
||||
|
|
|
@ -261,7 +261,7 @@ impl<T> TrieNode<T> {
|
|||
|
||||
impl<T> TrieNode<T> {
|
||||
fn each<'a>(&'a self, f: &fn(&uint, &'a T) -> bool) -> bool {
|
||||
for uint::range(0, self.children.len()) |idx| {
|
||||
foreach idx in range(0u, self.children.len()) {
|
||||
match self.children[idx] {
|
||||
Internal(ref x) => if !x.each(|i,t| f(i,t)) { return false },
|
||||
External(k, ref v) => if !f(&k, v) { return false },
|
||||
|
@ -396,7 +396,7 @@ pub fn check_integrity<T>(trie: &TrieNode<T>) {
|
|||
#[cfg(test)]
|
||||
mod test_map {
|
||||
use super::*;
|
||||
use option::{Some, None};
|
||||
use prelude::*;
|
||||
use uint;
|
||||
|
||||
#[test]
|
||||
|
@ -429,7 +429,7 @@ mod test_map {
|
|||
check_integrity(&trie.root);
|
||||
}
|
||||
|
||||
for uint::range(0, n) |x| {
|
||||
foreach x in range(0u, n) {
|
||||
assert!(trie.contains_key(&x));
|
||||
assert!(!trie.insert(x, x + 1));
|
||||
check_integrity(&trie.root);
|
||||
|
|
|
@ -436,9 +436,9 @@ mod tests {
|
|||
use cell::Cell;
|
||||
use comm;
|
||||
use option::*;
|
||||
use prelude::*;
|
||||
use super::{Exclusive, UnsafeAtomicRcBox, atomically};
|
||||
use task;
|
||||
use uint;
|
||||
use util;
|
||||
|
||||
#[test]
|
||||
|
@ -458,13 +458,13 @@ mod tests {
|
|||
|
||||
let total = Exclusive::new(~0);
|
||||
|
||||
for uint::range(0, num_tasks) |_i| {
|
||||
foreach _ in range(0u, num_tasks) {
|
||||
let total = total.clone();
|
||||
let (port, chan) = comm::stream();
|
||||
futures.push(port);
|
||||
|
||||
do task::spawn || {
|
||||
for uint::range(0, count) |_i| {
|
||||
foreach _ in range(0u, count) {
|
||||
do total.with |count| {
|
||||
**count += 1;
|
||||
}
|
||||
|
|
|
@ -473,7 +473,7 @@ pub fn each_permutation<T:Clone>(values: &[T], fun: &fn(perm : &[T]) -> bool) ->
|
|||
indices.swap(k, l);
|
||||
indices.mut_slice(k+1, length).reverse();
|
||||
// fixup permutation based on indices
|
||||
for uint::range(k, length) |i| {
|
||||
foreach i in range(k, length) {
|
||||
permutation[i] = values[indices[i]].clone();
|
||||
}
|
||||
}
|
||||
|
@ -1461,7 +1461,7 @@ impl<T> OwnedVector<T> for ~[T] {
|
|||
assert!(newlen <= oldlen);
|
||||
unsafe {
|
||||
// This loop is optimized out for non-drop types.
|
||||
for uint::range(newlen, oldlen) |i| {
|
||||
foreach i in range(newlen, oldlen) {
|
||||
ptr::read_and_zero_ptr(ptr::mut_offset(p, i as int));
|
||||
}
|
||||
}
|
||||
|
@ -1477,7 +1477,7 @@ impl<T> OwnedVector<T> for ~[T] {
|
|||
let len = self.len();
|
||||
let mut deleted: uint = 0;
|
||||
|
||||
for uint::range(0, len) |i| {
|
||||
foreach i in range(0u, len) {
|
||||
if !f(&self[i]) {
|
||||
deleted += 1;
|
||||
} else if deleted > 0 {
|
||||
|
@ -1561,7 +1561,7 @@ impl<T:Clone> OwnedCopyableVector<T> for ~[T] {
|
|||
let new_len = self.len() + rhs.len();
|
||||
self.reserve(new_len);
|
||||
|
||||
for uint::range(0u, rhs.len()) |i| {
|
||||
foreach i in range(0u, rhs.len()) {
|
||||
self.push(unsafe { raw::get(rhs, i) })
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@ source code snippets, etc.
|
|||
*/
|
||||
|
||||
use std::cmp;
|
||||
use std::uint;
|
||||
use extra::serialize::{Encodable, Decodable, Encoder, Decoder};
|
||||
|
||||
pub trait Pos {
|
||||
|
@ -364,7 +363,7 @@ impl CodeMap {
|
|||
let lo = self.lookup_char_pos(sp.lo);
|
||||
let hi = self.lookup_char_pos(sp.hi);
|
||||
let mut lines = ~[];
|
||||
for uint::range(lo.line - 1u, hi.line as uint) |i| {
|
||||
foreach i in range(lo.line - 1u, hi.line as uint) {
|
||||
lines.push(i);
|
||||
};
|
||||
return @FileLines {file: lo.file, lines: lines};
|
||||
|
|
|
@ -12,7 +12,6 @@ use codemap::{Pos, span};
|
|||
use codemap;
|
||||
|
||||
use std::io;
|
||||
use std::uint;
|
||||
use std::local_data;
|
||||
use extra::term;
|
||||
|
||||
|
@ -306,7 +305,7 @@ fn highlight_lines(cm: @codemap::CodeMap,
|
|||
s.push_char(' ');
|
||||
}
|
||||
let orig = fm.get_line(lines.lines[0] as int);
|
||||
for uint::range(0u,left-skip) |pos| {
|
||||
foreach pos in range(0u, left-skip) {
|
||||
let curChar = (orig[pos] as char);
|
||||
// Whenever a tab occurs on the previous line, we insert one on
|
||||
// the error-point-squiggly-line as well (instead of a space).
|
||||
|
|
|
@ -14,7 +14,6 @@ encodable.rs for more.
|
|||
*/
|
||||
|
||||
use std::vec;
|
||||
use std::uint;
|
||||
|
||||
use ast::{MetaItem, item, expr, m_mutbl};
|
||||
use codemap::span;
|
||||
|
@ -84,7 +83,7 @@ fn decodable_substructure(cx: @ExtCtxt, span: span,
|
|||
cx.expr_ident(span, substr.type_ident)
|
||||
} else {
|
||||
let mut fields = vec::with_capacity(n);
|
||||
for uint::range(0, n) |i| {
|
||||
foreach i in range(0, n) {
|
||||
fields.push(getarg(fmt!("_field%u", i).to_managed(), i));
|
||||
}
|
||||
cx.expr_call_ident(span, substr.type_ident, fields)
|
||||
|
@ -126,7 +125,7 @@ fn decodable_substructure(cx: @ExtCtxt, span: span,
|
|||
cx.expr_ident(span, name)
|
||||
} else {
|
||||
let mut fields = vec::with_capacity(n);
|
||||
for uint::range(0, n) |i| {
|
||||
foreach i in range(0u, n) {
|
||||
fields.push(getarg(i));
|
||||
}
|
||||
cx.expr_call_ident(span, name, fields)
|
||||
|
|
|
@ -170,7 +170,6 @@ use ext::build::AstBuilder;
|
|||
use codemap::{span,respan};
|
||||
use opt_vec;
|
||||
|
||||
use std::uint;
|
||||
use std::vec;
|
||||
|
||||
pub use self::ty::*;
|
||||
|
@ -580,13 +579,13 @@ impl<'self> MethodDef<'self> {
|
|||
let mut raw_fields = ~[]; // ~[[fields of self],
|
||||
// [fields of next Self arg], [etc]]
|
||||
let mut patterns = ~[];
|
||||
for uint::range(0, self_args.len()) |i| {
|
||||
foreach i in range(0u, self_args.len()) {
|
||||
let (pat, ident_expr) = create_struct_pattern(cx, span,
|
||||
type_ident, struct_def,
|
||||
fmt!("__self_%u", i), ast::m_imm);
|
||||
patterns.push(pat);
|
||||
raw_fields.push(ident_expr);
|
||||
};
|
||||
}
|
||||
|
||||
// transpose raw_fields
|
||||
let fields = match raw_fields {
|
||||
|
@ -992,7 +991,7 @@ fn create_enum_variant_pattern(cx: @ExtCtxt,
|
|||
|
||||
let mut paths = ~[];
|
||||
let mut ident_expr = ~[];
|
||||
for uint::range(0, variant_args.len()) |i| {
|
||||
foreach i in range(0u, variant_args.len()) {
|
||||
let path = cx.path_ident(span,
|
||||
cx.ident_of(fmt!("%s_%u", prefix, i)));
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@ use parse::token::{Token, EOF, to_str, nonterminal, get_ident_interner, ident_to
|
|||
use parse::token;
|
||||
|
||||
use std::hashmap::HashMap;
|
||||
use std::uint;
|
||||
use std::vec;
|
||||
|
||||
/* This is an Earley-like parser, without support for in-grammar nonterminals,
|
||||
|
@ -280,7 +279,7 @@ pub fn parse(
|
|||
// most of the time.
|
||||
|
||||
// Only touch the binders we have actually bound
|
||||
for uint::range(ei.match_lo, ei.match_hi) |idx| {
|
||||
foreach idx in range(ei.match_lo, ei.match_hi) {
|
||||
let sub = ei.matches[idx].clone();
|
||||
new_pos.matches[idx]
|
||||
.push(@matched_seq(sub,
|
||||
|
@ -321,7 +320,7 @@ pub fn parse(
|
|||
let mut new_ei = ei.clone();
|
||||
new_ei.idx += 1u;
|
||||
//we specifically matched zero repeats.
|
||||
for uint::range(match_idx_lo, match_idx_hi) |idx| {
|
||||
foreach idx in range(match_idx_lo, match_idx_hi) {
|
||||
new_ei.matches[idx].push(@matched_seq(~[], sp));
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@ use print::pprust;
|
|||
|
||||
use std::io;
|
||||
use std::u64;
|
||||
use std::uint;
|
||||
|
||||
// The @ps is stored here to prevent recursive type.
|
||||
pub enum ann_node<'self> {
|
||||
|
@ -1791,7 +1790,7 @@ pub fn print_generics(s: @ps, generics: &ast::Generics) {
|
|||
}
|
||||
|
||||
let mut ints = ~[];
|
||||
for uint::range(0, total) |i| {
|
||||
foreach i in range(0u, total) {
|
||||
ints.push(i);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ pub mod kitties {
|
|||
}
|
||||
|
||||
impl cat {
|
||||
priv fn nap(&self) { for uint::range(1, 10000u) |_i|{}}
|
||||
priv fn nap(&self) {}
|
||||
}
|
||||
|
||||
pub fn cat(in_x : uint, in_y : int) -> cat {
|
||||
|
|
|
@ -31,19 +31,19 @@ fn ascending<M: MutableMap<uint, uint>>(map: &mut M, n_keys: uint) {
|
|||
io::println(" Ascending integers:");
|
||||
|
||||
do timed("insert") {
|
||||
for uint::range(0, n_keys) |i| {
|
||||
foreach i in range(0u, n_keys) {
|
||||
map.insert(i, i + 1);
|
||||
}
|
||||
}
|
||||
|
||||
do timed("search") {
|
||||
for uint::range(0, n_keys) |i| {
|
||||
foreach i in range(0u, n_keys) {
|
||||
assert_eq!(map.find(&i).unwrap(), &(i + 1));
|
||||
}
|
||||
}
|
||||
|
||||
do timed("remove") {
|
||||
for uint::range(0, n_keys) |i| {
|
||||
foreach i in range(0, n_keys) {
|
||||
assert!(map.remove(&i));
|
||||
}
|
||||
}
|
||||
|
@ -74,19 +74,19 @@ fn descending<M: MutableMap<uint, uint>>(map: &mut M, n_keys: uint) {
|
|||
fn vector<M: MutableMap<uint, uint>>(map: &mut M, n_keys: uint, dist: &[uint]) {
|
||||
|
||||
do timed("insert") {
|
||||
for uint::range(0, n_keys) |i| {
|
||||
foreach i in range(0u, n_keys) {
|
||||
map.insert(dist[i], i + 1);
|
||||
}
|
||||
}
|
||||
|
||||
do timed("search") {
|
||||
for uint::range(0, n_keys) |i| {
|
||||
foreach i in range(0u, n_keys) {
|
||||
assert_eq!(map.find(&dist[i]).unwrap(), &(i + 1));
|
||||
}
|
||||
}
|
||||
|
||||
do timed("remove") {
|
||||
for uint::range(0, n_keys) |i| {
|
||||
foreach i in range(0u, n_keys) {
|
||||
assert!(map.remove(&dist[i]));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,11 +46,11 @@ impl Results {
|
|||
{
|
||||
let mut set = f();
|
||||
do timed(&mut self.sequential_ints) {
|
||||
for uint::range(0, num_keys) |i| {
|
||||
foreach i in range(0u, num_keys) {
|
||||
set.insert(i);
|
||||
}
|
||||
|
||||
for uint::range(0, num_keys) |i| {
|
||||
foreach i in range(0u, num_keys) {
|
||||
assert!(set.contains(&i));
|
||||
}
|
||||
}
|
||||
|
@ -67,12 +67,12 @@ impl Results {
|
|||
|
||||
{
|
||||
let mut set = f();
|
||||
for uint::range(0, num_keys) |i| {
|
||||
foreach i in range(0u, num_keys) {
|
||||
set.insert(i);
|
||||
}
|
||||
|
||||
do timed(&mut self.delete_ints) {
|
||||
for uint::range(0, num_keys) |i| {
|
||||
foreach i in range(0u, num_keys) {
|
||||
assert!(set.remove(&i));
|
||||
}
|
||||
}
|
||||
|
@ -88,12 +88,12 @@ impl Results {
|
|||
{
|
||||
let mut set = f();
|
||||
do timed(&mut self.sequential_strings) {
|
||||
for uint::range(0, num_keys) |i| {
|
||||
foreach i in range(0u, num_keys) {
|
||||
let s = uint::to_str(i);
|
||||
set.insert(s);
|
||||
}
|
||||
|
||||
for uint::range(0, num_keys) |i| {
|
||||
foreach i in range(0u, num_keys) {
|
||||
let s = uint::to_str(i);
|
||||
assert!(set.contains(&s));
|
||||
}
|
||||
|
@ -112,11 +112,11 @@ impl Results {
|
|||
|
||||
{
|
||||
let mut set = f();
|
||||
for uint::range(0, num_keys) |i| {
|
||||
foreach i in range(0u, num_keys) {
|
||||
set.insert(uint::to_str(i));
|
||||
}
|
||||
do timed(&mut self.delete_strings) {
|
||||
for uint::range(0, num_keys) |i| {
|
||||
foreach i in range(0u, num_keys) {
|
||||
assert!(set.remove(&uint::to_str(i)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ fn read_line() {
|
|||
let path = Path(env!("CFG_SRC_DIR"))
|
||||
.push_rel(&Path("src/test/bench/shootout-k-nucleotide.data"));
|
||||
|
||||
for int::range(0, 3) |_i| {
|
||||
foreach _ in range(0, 3) {
|
||||
let reader = io::file_reader(&path).unwrap();
|
||||
while !reader.eof() {
|
||||
reader.read_line();
|
||||
|
@ -119,7 +119,7 @@ fn vec_push_all() {
|
|||
let mut r = rand::rng();
|
||||
|
||||
let mut v = ~[];
|
||||
for uint::range(0, 1500) |i| {
|
||||
foreach i in range(0u, 1500) {
|
||||
let mut rv = vec::from_elem(r.gen_uint_range(0, i + 1), i);
|
||||
if r.gen() {
|
||||
v.push_all(rv);
|
||||
|
@ -133,7 +133,7 @@ fn vec_push_all() {
|
|||
|
||||
fn is_utf8_ascii() {
|
||||
let mut v : ~[u8] = ~[];
|
||||
for uint::range(0, 20000) |_| {
|
||||
foreach _ in range(0u, 20000) {
|
||||
v.push('b' as u8);
|
||||
if !str::is_utf8(v) {
|
||||
fail!("is_utf8 failed");
|
||||
|
@ -144,7 +144,7 @@ fn is_utf8_ascii() {
|
|||
fn is_utf8_multibyte() {
|
||||
let s = "b¢€𤭢";
|
||||
let mut v : ~[u8]= ~[];
|
||||
for uint::range(0, 5000) |_| {
|
||||
foreach _ in range(0u, 5000) {
|
||||
v.push_all(s.as_bytes());
|
||||
if !str::is_utf8(v) {
|
||||
fail!("is_utf8 failed");
|
||||
|
|
|
@ -23,7 +23,7 @@ fn main() {
|
|||
|
||||
let n = uint::from_str(args[1]).get();
|
||||
|
||||
for uint::range(0u, n) |i| {
|
||||
foreach i in range(0u, n) {
|
||||
let x = uint::to_str(i);
|
||||
info!(x);
|
||||
}
|
||||
|
|
|
@ -64,12 +64,12 @@ fn run(args: &[~str]) {
|
|||
let num_bytes = 100;
|
||||
let start = extra::time::precise_time_s();
|
||||
let mut worker_results = ~[];
|
||||
for uint::range(0, workers) |_i| {
|
||||
foreach _ in range(0u, workers) {
|
||||
let to_child = to_child.clone();
|
||||
let mut builder = task::task();
|
||||
builder.future_result(|r| worker_results.push(r));
|
||||
do builder.spawn {
|
||||
for uint::range(0, size / workers) |_i| {
|
||||
foreach _ in range(0u, size / workers) {
|
||||
//error!("worker %?: sending %? bytes", i, num_bytes);
|
||||
to_child.send(bytes(num_bytes));
|
||||
}
|
||||
|
|
|
@ -58,12 +58,12 @@ fn run(args: &[~str]) {
|
|||
let num_bytes = 100;
|
||||
let start = extra::time::precise_time_s();
|
||||
let mut worker_results = ~[];
|
||||
for uint::range(0, workers) |_i| {
|
||||
foreach _ in range(0u, workers) {
|
||||
let to_child = to_child.clone();
|
||||
let mut builder = task::task();
|
||||
builder.future_result(|r| worker_results.push(r));
|
||||
do builder.spawn {
|
||||
for uint::range(0, size / workers) |_i| {
|
||||
foreach _ in range(0u, size / workers) {
|
||||
//error!("worker %?: sending %? bytes", i, num_bytes);
|
||||
to_child.send(bytes(num_bytes));
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ fn thread_ring(i: uint, count: uint, num_chan: pipe, num_port: pipe) {
|
|||
let mut num_chan = Some(num_chan);
|
||||
let mut num_port = Some(num_port);
|
||||
// Send/Receive lots of messages.
|
||||
for uint::range(0u, count) |j| {
|
||||
foreach j in range(0u, count) {
|
||||
//error!("task %?, iter %?", i, j);
|
||||
let num_chan2 = num_chan.take_unwrap();
|
||||
let num_port2 = num_port.take_unwrap();
|
||||
|
@ -90,7 +90,7 @@ fn main() {
|
|||
// create the ring
|
||||
let mut futures = ~[];
|
||||
|
||||
for uint::range(1u, num_tasks) |i| {
|
||||
foreach i in range(1u, num_tasks) {
|
||||
//error!("spawning %?", i);
|
||||
let (new_chan, num_port) = init();
|
||||
let num_chan2 = Cell::new(num_chan.take());
|
||||
|
|
|
@ -53,7 +53,7 @@ fn thread_ring(i: uint, count: uint, num_chan: pipe, num_port: pipe) {
|
|||
let mut num_chan = Some(num_chan);
|
||||
let mut num_port = Some(num_port);
|
||||
// Send/Receive lots of messages.
|
||||
for uint::range(0u, count) |j| {
|
||||
foreach j in range(0u, count) {
|
||||
//error!("task %?, iter %?", i, j);
|
||||
let num_chan2 = num_chan.take_unwrap();
|
||||
let num_port2 = num_port.take_unwrap();
|
||||
|
@ -86,7 +86,7 @@ fn main() {
|
|||
// create the ring
|
||||
let mut futures = ~[];
|
||||
|
||||
for uint::range(1u, num_tasks) |i| {
|
||||
foreach i in range(1u, num_tasks) {
|
||||
//error!("spawning %?", i);
|
||||
let (new_chan, num_port) = init();
|
||||
let num_chan2 = Cell::new(num_chan.take());
|
||||
|
|
|
@ -38,11 +38,11 @@ impl Noise2DContext {
|
|||
pub fn new() -> Noise2DContext {
|
||||
let mut r = rand::rng();
|
||||
let mut rgradients = [ Vec2 { x: 0.0, y: 0.0 }, ..256 ];
|
||||
for int::range(0, 256) |i| {
|
||||
foreach i in range(0, 256) {
|
||||
rgradients[i] = random_gradient(&mut r);
|
||||
}
|
||||
let mut permutations = [ 0, ..256 ];
|
||||
for int::range(0, 256) |i| {
|
||||
foreach i in range(0, 256) {
|
||||
permutations[i] = i;
|
||||
}
|
||||
r.shuffle_mut(permutations);
|
||||
|
@ -106,8 +106,8 @@ fn main() {
|
|||
let mut pixels = [0f32, ..256*256];
|
||||
let n2d = ~Noise2DContext::new();
|
||||
do 100.times {
|
||||
for int::range(0, 256) |y| {
|
||||
for int::range(0, 256) |x| {
|
||||
foreach y in range(0, 256) {
|
||||
foreach x in range(0, 256) {
|
||||
let v = n2d.get(
|
||||
x as f32 * 0.1f32,
|
||||
y as f32 * 0.1f32
|
||||
|
@ -117,8 +117,8 @@ fn main() {
|
|||
};
|
||||
};
|
||||
|
||||
for int::range(0, 256) |y| {
|
||||
for int::range(0, 256) |x| {
|
||||
foreach y in range(0, 256) {
|
||||
foreach x in range(0, 256) {
|
||||
print(symbols[pixels[y*256+x] / 0.2f32 as int]);
|
||||
}
|
||||
println("");
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
use std::from_str::FromStr;
|
||||
use std::i32::range;
|
||||
use std::os;
|
||||
use std::vec::MutableVector;
|
||||
use std::vec;
|
||||
|
@ -42,7 +41,7 @@ fn fannkuch_redux(n: i32) -> i32 {
|
|||
}
|
||||
|
||||
let k2 = (k+1) >> 1;
|
||||
for range(0, k2) |i| {
|
||||
foreach i in range(0i32, k2) {
|
||||
let (perm_i, perm_k_i) = {
|
||||
(perm.unsafe_get(i as uint),
|
||||
perm.unsafe_get((k-i) as uint))
|
||||
|
|
|
@ -2,7 +2,7 @@ use std::cast::transmute;
|
|||
use std::from_str::FromStr;
|
||||
use std::libc::{FILE, STDOUT_FILENO, c_int, fdopen, fputc, fputs, fwrite, size_t};
|
||||
use std::os;
|
||||
use std::uint::{min, range};
|
||||
use std::uint::min;
|
||||
use std::vec::bytes::copy_memory;
|
||||
use std::vec;
|
||||
|
||||
|
@ -165,7 +165,7 @@ impl RandomFasta {
|
|||
let mut buf = [0, ..LINE_LEN + 1];
|
||||
|
||||
do lines.times {
|
||||
for range(0, LINE_LEN) |i| {
|
||||
foreach i in range(0u, LINE_LEN) {
|
||||
buf[i] = self.nextc();
|
||||
}
|
||||
buf[LINE_LEN] = '\n' as u8;
|
||||
|
@ -174,7 +174,7 @@ impl RandomFasta {
|
|||
1,
|
||||
self.stdout);
|
||||
}
|
||||
for range(0, chars_left) |i| {
|
||||
foreach i in range(0u, chars_left) {
|
||||
buf[i] = self.nextc();
|
||||
}
|
||||
fwrite(transmute(&buf[0]), chars_left as size_t, 1, self.stdout);
|
||||
|
|
|
@ -81,7 +81,7 @@ fn make_random_fasta(wr: @io::Writer,
|
|||
last: rng.next()
|
||||
};
|
||||
let mut op: ~str = ~"";
|
||||
for uint::range(0u, n as uint) |_i| {
|
||||
foreach _ in range(0u, n as uint) {
|
||||
op.push_char(select_random(myrandom_next(rng, 100u32),
|
||||
genelist.clone()));
|
||||
if op.len() >= LINE_LENGTH {
|
||||
|
@ -96,7 +96,7 @@ fn make_repeat_fasta(wr: @io::Writer, id: ~str, desc: ~str, s: ~str, n: int) {
|
|||
wr.write_line(~">" + id + " " + desc);
|
||||
let mut op = str::with_capacity( LINE_LENGTH );
|
||||
let sl = s.len();
|
||||
for uint::range(0u, n as uint) |i| {
|
||||
foreach i in range(0u, n as uint) {
|
||||
if (op.len() >= LINE_LENGTH) {
|
||||
wr.write_line( op );
|
||||
op = str::with_capacity( LINE_LENGTH );
|
||||
|
|
|
@ -44,7 +44,7 @@ impl Code {
|
|||
|
||||
fn pack(string: &str) -> Code {
|
||||
let mut code = Code(0u64);
|
||||
for uint::range(0, string.len()) |i| {
|
||||
foreach i in range(0u, string.len()) {
|
||||
code = code.push_char(string[i]);
|
||||
}
|
||||
code
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use std::cast::transmute;
|
||||
use std::from_str::FromStr;
|
||||
use std::i32::range;
|
||||
use std::libc::{STDOUT_FILENO, c_int, fdopen, fputc};
|
||||
use std::os;
|
||||
|
||||
|
@ -20,9 +19,9 @@ fn main() {
|
|||
let mode = "w";
|
||||
let stdout = fdopen(STDOUT_FILENO as c_int, transmute(&mode[0]));
|
||||
|
||||
for range(0, h) |y| {
|
||||
foreach y in range(0i32, h) {
|
||||
let y = y as f64;
|
||||
for range(0, w) |x| {
|
||||
foreach x in range(0i32, w) {
|
||||
let mut Zr = 0f64;
|
||||
let mut Zi = 0f64;
|
||||
let mut Tr = 0f64;
|
||||
|
@ -30,7 +29,7 @@ fn main() {
|
|||
let Cr = 2.0 * (x as f64) / (w as f64) - 1.5;
|
||||
let Ci = 2.0 * (y as f64) / (h as f64) - 1.0;
|
||||
|
||||
for range(0, ITER as i32) |_| {
|
||||
foreach _ in range(0i32, ITER as i32) {
|
||||
if Tr + Ti > LIMIT * LIMIT {
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use std::from_str::FromStr;
|
||||
use std::os;
|
||||
use std::uint::range;
|
||||
|
||||
static PI: f64 = 3.141592653589793;
|
||||
static SOLAR_MASS: f64 = 4.0 * PI * PI;
|
||||
|
@ -81,8 +80,8 @@ struct Planet {
|
|||
fn advance(bodies: &mut [Planet, ..N_BODIES], dt: f64, steps: i32) {
|
||||
let mut d = [ 0.0, ..3 ];
|
||||
do (steps as uint).times {
|
||||
for range(0, N_BODIES) |i| {
|
||||
for range(i + 1, N_BODIES) |j| {
|
||||
foreach i in range(0u, N_BODIES) {
|
||||
foreach j in range(i + 1, N_BODIES) {
|
||||
d[0] = bodies[i].x[0] - bodies[j].x[0];
|
||||
d[1] = bodies[i].x[1] - bodies[j].x[1];
|
||||
d[2] = bodies[i].x[2] - bodies[j].x[2];
|
||||
|
@ -113,13 +112,13 @@ fn advance(bodies: &mut [Planet, ..N_BODIES], dt: f64, steps: i32) {
|
|||
fn energy(bodies: &[Planet, ..N_BODIES]) -> f64 {
|
||||
let mut e = 0.0;
|
||||
let mut d = [ 0.0, ..3 ];
|
||||
for range(0, N_BODIES) |i| {
|
||||
for range(0, 3) |k| {
|
||||
foreach i in range(0u, N_BODIES) {
|
||||
foreach k in range(0u, 3) {
|
||||
e += bodies[i].mass * bodies[i].v[k] * bodies[i].v[k] / 2.0;
|
||||
}
|
||||
|
||||
for range(i + 1, N_BODIES) |j| {
|
||||
for range(0, 3) |k| {
|
||||
foreach j in range(i + 1, N_BODIES) {
|
||||
foreach k in range(0u, 3) {
|
||||
d[k] = bodies[i].x[k] - bodies[j].x[k];
|
||||
}
|
||||
let dist = (d[0]*d[0] + d[1]*d[1] + d[2]*d[2]).sqrt();
|
||||
|
@ -130,8 +129,8 @@ fn energy(bodies: &[Planet, ..N_BODIES]) -> f64 {
|
|||
}
|
||||
|
||||
fn offset_momentum(bodies: &mut [Planet, ..N_BODIES]) {
|
||||
for range(0, N_BODIES) |i| {
|
||||
for range(0, 3) |k| {
|
||||
foreach i in range(0u, N_BODIES) {
|
||||
foreach k in range(0u, 3) {
|
||||
bodies[0].v[k] -= bodies[i].v[k] * bodies[i].mass / SOLAR_MASS;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@ extern mod extra;
|
|||
|
||||
use extra::{time, getopts};
|
||||
use std::comm::*;
|
||||
use std::int::range;
|
||||
use std::io::WriterUtil;
|
||||
use std::io;
|
||||
use std::os;
|
||||
|
@ -84,7 +83,7 @@ fn stress_task(id: int) {
|
|||
|
||||
fn stress(num_tasks: int) {
|
||||
let mut results = ~[];
|
||||
for range(0, num_tasks) |i| {
|
||||
foreach i in range(0, num_tasks) {
|
||||
let mut builder = task::task();
|
||||
builder.future_result(|r| results.push(r));
|
||||
do builder.spawn {
|
||||
|
@ -117,8 +116,8 @@ fn main() {
|
|||
|
||||
let out = io::stdout();
|
||||
|
||||
for range(1, max + 1) |n| {
|
||||
for range(0, num_trials) |_i| {
|
||||
foreach n in range(1, max + 1) {
|
||||
foreach _ in range(0, num_trials) {
|
||||
let start = time::precise_time_ns();
|
||||
let fibn = fib(n);
|
||||
let stop = time::precise_time_ns();
|
||||
|
|
|
@ -19,13 +19,13 @@ use std::os;
|
|||
use std::uint;
|
||||
|
||||
fn append_sequential(min: uint, max: uint, map: &mut SmallIntMap<uint>) {
|
||||
for uint::range(min, max) |i| {
|
||||
foreach i in range(min, max) {
|
||||
map.insert(i, i + 22u);
|
||||
}
|
||||
}
|
||||
|
||||
fn check_sequential(min: uint, max: uint, map: &SmallIntMap<uint>) {
|
||||
for uint::range(min, max) |i| {
|
||||
foreach i in range(min, max) {
|
||||
assert_eq!(*map.get(&i), i + 22u);
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ fn main() {
|
|||
let mut checkf = 0.0;
|
||||
let mut appendf = 0.0;
|
||||
|
||||
for uint::range(0u, rep) |_r| {
|
||||
foreach _ in range(0u, rep) {
|
||||
let mut map = SmallIntMap::new();
|
||||
let start = extra::time::precise_time_s();
|
||||
append_sequential(0u, max, &mut map);
|
||||
|
|
|
@ -56,8 +56,8 @@ impl Sudoku {
|
|||
}
|
||||
|
||||
pub fn equal(&self, other: &Sudoku) -> bool {
|
||||
for u8::range(0u8, 9u8) |row| {
|
||||
for u8::range(0u8, 9u8) |col| {
|
||||
foreach row in range(0u8, 9u8) {
|
||||
foreach col in range(0u8, 9u8) {
|
||||
if self.grid[row][col] != other.grid[row][col] {
|
||||
return false;
|
||||
}
|
||||
|
@ -87,9 +87,9 @@ impl Sudoku {
|
|||
}
|
||||
|
||||
pub fn write(&self, writer: @io::Writer) {
|
||||
for u8::range(0u8, 9u8) |row| {
|
||||
foreach row in range(0u8, 9u8) {
|
||||
writer.write_str(fmt!("%u", self.grid[row][0] as uint));
|
||||
for u8::range(1u8, 9u8) |col| {
|
||||
foreach col in range(1u8, 9u8) {
|
||||
writer.write_str(fmt!(" %u", self.grid[row][col] as uint));
|
||||
}
|
||||
writer.write_char('\n');
|
||||
|
@ -99,8 +99,8 @@ impl Sudoku {
|
|||
// solve sudoku grid
|
||||
pub fn solve(&mut self) {
|
||||
let mut work: ~[(u8, u8)] = ~[]; /* queue of uncolored fields */
|
||||
for u8::range(0u8, 9u8) |row| {
|
||||
for u8::range(0u8, 9u8) |col| {
|
||||
foreach row in range(0u8, 9u8) {
|
||||
foreach col in range(0u8, 9u8) {
|
||||
let color = self.grid[row][col];
|
||||
if color == 0u8 {
|
||||
work.push((row, col));
|
||||
|
@ -143,7 +143,7 @@ impl Sudoku {
|
|||
|
||||
// find colors available in neighbourhood of (row, col)
|
||||
fn drop_colors(&mut self, avail: &mut Colors, row: u8, col: u8) {
|
||||
for u8::range(0u8, 9u8) |idx| {
|
||||
foreach idx in range(0u8, 9u8) {
|
||||
avail.remove(self.grid[idx][col]); /* check same column fields */
|
||||
avail.remove(self.grid[row][idx]); /* check same row fields */
|
||||
}
|
||||
|
@ -151,8 +151,10 @@ impl Sudoku {
|
|||
// check same block fields
|
||||
let row0 = (row / 3u8) * 3u8;
|
||||
let col0 = (col / 3u8) * 3u8;
|
||||
for u8::range(row0, row0 + 3u8) |alt_row| {
|
||||
for u8::range(col0, col0 + 3u8) |alt_col| { avail.remove(self.grid[alt_row][alt_col]); }
|
||||
foreach alt_row in range(row0, row0 + 3u8) {
|
||||
foreach alt_col in range(col0, col0 + 3u8) {
|
||||
avail.remove(self.grid[alt_row][alt_col]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::uint;
|
||||
|
||||
fn not_bool(f: &fn(int) -> ~str) -> bool {}
|
||||
|
||||
fn main() {
|
||||
for uint::range(0, 100000) |_i| { //~ ERROR A for-loop body must return (), but
|
||||
false
|
||||
};
|
||||
for not_bool |_i| {
|
||||
//~^ ERROR A `for` loop iterator should expect a closure that returns `bool`
|
||||
~"hi"
|
||||
};
|
||||
for uint::range(0, 100000) |_i| { //~ ERROR A for-loop body must return (), but
|
||||
~"hi"
|
||||
};
|
||||
for not_bool() |_i| {
|
||||
//~^ ERROR A `for` loop iterator should expect a closure that returns `bool`
|
||||
};
|
||||
}
|
|
@ -17,11 +17,11 @@ fn to_str(u: uint) -> ~str { fail!(); }
|
|||
fn uuid_random() -> uint { fail!(); }
|
||||
|
||||
fn main() {
|
||||
do uint::range(0, 100000) |_i| { //~ ERROR Do-block body must return bool, but
|
||||
do range(0u, 100000).advance |_i| { //~ ERROR Do-block body must return bool, but
|
||||
};
|
||||
// should get a more general message if the callback
|
||||
// doesn't return nil
|
||||
do uint::range(0, 100000) |_i| { //~ ERROR mismatched types
|
||||
do range(0u, 100000).advance |_i| { //~ ERROR mismatched types
|
||||
~"str"
|
||||
};
|
||||
}
|
||||
|
|
|
@ -14,7 +14,5 @@ fn test(_x: ~uint) {}
|
|||
|
||||
fn main() {
|
||||
let i = ~3;
|
||||
for uint::range(0, 10) |_x| {
|
||||
test(i); //~ ERROR cannot move out
|
||||
}
|
||||
let _f = || test(i); //~ ERROR cannot move out
|
||||
}
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
// error-pattern:method `nap` is private
|
||||
|
||||
mod kitties {
|
||||
use std::uint;
|
||||
|
||||
pub struct cat {
|
||||
priv meows : uint,
|
||||
|
||||
|
@ -20,7 +18,7 @@ mod kitties {
|
|||
}
|
||||
|
||||
impl cat {
|
||||
priv fn nap(&self) { uint::range(1u, 10000u, |_i| false); }
|
||||
priv fn nap(&self) {}
|
||||
}
|
||||
|
||||
pub fn cat(in_x : uint, in_y : int) -> cat {
|
||||
|
|
|
@ -16,10 +16,10 @@ struct dog {
|
|||
|
||||
impl dog {
|
||||
pub fn chase_cat(&mut self) {
|
||||
for uint::range(0u, 10u) |_i| {
|
||||
let _f = || {
|
||||
let p: &'static mut uint = &mut self.food; //~ ERROR cannot infer an appropriate lifetime due to conflicting requirements
|
||||
*p = 3u;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,4 @@
|
|||
// error-pattern:moop
|
||||
extern mod extra;
|
||||
|
||||
use std::uint;
|
||||
|
||||
fn main() { for uint::range(0u, 10u) |_i| { fail!("moop"); } }
|
||||
fn main() { foreach _ in range(0u, 10u) { fail!("moop"); } }
|
||||
|
|
|
@ -15,7 +15,7 @@ fn main() {
|
|||
let count = @mut 0u;
|
||||
let mut map = std::hashmap::HashMap::new();
|
||||
let mut arr = ~[];
|
||||
for std::uint::range(0u, 10u) |i| {
|
||||
foreach i in range(0u, 10u) {
|
||||
arr.push(@~"key stuff");
|
||||
map.insert(arr.clone(), arr + &[@~"value stuff"]);
|
||||
if arr.len() == 5 {
|
||||
|
|
|
@ -23,7 +23,7 @@ fn add_int(x: &mut Ints, v: int) {
|
|||
|
||||
fn iter_ints(x: &Ints, f: &fn(x: &int) -> bool) -> bool {
|
||||
let l = x.values.len();
|
||||
uint::range(0, l, |i| f(&x.values[i]))
|
||||
range(0u, l).advance(|i| f(&x.values[i]))
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
|
|
|
@ -83,7 +83,7 @@ fn cat(in_x : uint, in_y : int, in_name: ~str) -> cat {
|
|||
|
||||
|
||||
fn annoy_neighbors(critter: @noisy) {
|
||||
for uint::range(0u, 10u) |i| { critter.speak(); }
|
||||
foreach i in range(0u, 10) { critter.speak(); }
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
|
|
|
@ -75,7 +75,7 @@ class cat : map<int, bool> {
|
|||
|
||||
pub fn main() {
|
||||
let nyan : cat = cat(0, 2, "nyan");
|
||||
for uint::range(1u, 5u) |_i| { nyan.speak(); }
|
||||
foreach _ in range(1u, 5u) { nyan.speak(); }
|
||||
// cat returns true if uint input is greater than
|
||||
// the number of meows so far
|
||||
assert!((nyan.get(1)));
|
||||
|
|
|
@ -117,11 +117,11 @@ impl<T> cat<T> {
|
|||
|
||||
pub fn main() {
|
||||
let mut nyan: cat<~str> = cat::new(0, 2, ~"nyan");
|
||||
for uint::range(1, 5) |_| { nyan.speak(); }
|
||||
foreach _ in range(1u, 5) { nyan.speak(); }
|
||||
assert!(*nyan.find(&1).unwrap() == ~"nyan");
|
||||
assert_eq!(nyan.find(&10), None);
|
||||
let mut spotty: cat<cat_type> = cat::new(2, 57, tuxedo);
|
||||
for uint::range(0, 6) |_| { spotty.speak(); }
|
||||
foreach _ in range(0u, 6) { spotty.speak(); }
|
||||
assert_eq!(spotty.len(), 8);
|
||||
assert!((spotty.contains_key(&2)));
|
||||
assert_eq!(spotty.get(&3), &tuxedo);
|
||||
|
|
|
@ -63,6 +63,6 @@ pub fn main() {
|
|||
let mut nyan = cat(0u, 2, ~"nyan");
|
||||
nyan.eat();
|
||||
assert!((!nyan.eat()));
|
||||
for uint::range(1u, 10u) |_i| { nyan.speak(); };
|
||||
foreach _ in range(1u, 10u) { nyan.speak(); };
|
||||
assert!((nyan.eat()));
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ pub fn main() {
|
|||
let mut nyan = cat(0u, 2, ~"nyan");
|
||||
nyan.eat();
|
||||
assert!((!nyan.eat()));
|
||||
for uint::range(1u, 10u) |_i| {
|
||||
foreach _ in range(1u, 10u) {
|
||||
make_speak(nyan.clone());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ class cat : noisy, scratchy, bitey {
|
|||
}
|
||||
|
||||
fn annoy_neighbors<T:noisy>(critter: T) {
|
||||
for uint::range(0u, 10u) |i| {
|
||||
foreach i in range(0u, 10u) {
|
||||
let what = critter.speak();
|
||||
info!("%u %d", i, what);
|
||||
}
|
||||
|
|
|
@ -19,6 +19,6 @@ pub fn main() {
|
|||
let mut nyan = cat(0u, 2, ~"nyan");
|
||||
nyan.eat();
|
||||
assert!((!nyan.eat()));
|
||||
for uint::range(1u, 10u) |_i| { nyan.speak(); };
|
||||
foreach _ in range(1u, 10u) { nyan.speak(); };
|
||||
assert!((nyan.eat()));
|
||||
}
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::uint;
|
||||
|
||||
struct cat {
|
||||
priv meows : uint,
|
||||
|
||||
|
@ -54,6 +52,6 @@ pub fn main() {
|
|||
let mut nyan = cat(0u, 2, ~"nyan");
|
||||
nyan.eat();
|
||||
assert!((!nyan.eat()));
|
||||
for uint::range(1u, 10u) |_i| { nyan.speak(); };
|
||||
foreach _ in range(1u, 10u) { nyan.speak(); };
|
||||
assert!((nyan.eat()));
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
extern mod extra;
|
||||
|
||||
use std::io;
|
||||
use std::uint;
|
||||
use std::vec;
|
||||
|
||||
trait methods {
|
||||
|
@ -41,7 +40,7 @@ pub fn main() {
|
|||
let bools = ~[false, false, true, false, false, true, true, false];
|
||||
let bools2 = to_bools(Storage{storage: ~[0b01100100]});
|
||||
|
||||
for uint::range(0, 8) |i| {
|
||||
foreach i in range(0u, 8) {
|
||||
printfln!("%u => %u vs %u", i, bools[i] as uint, bools2[i] as uint);
|
||||
}
|
||||
|
||||
|
|
|
@ -134,13 +134,13 @@ impl Canvas for AsciiArt {
|
|||
|
||||
fn add_rect(&mut self, shape: Rect) {
|
||||
// Add the top and bottom lines.
|
||||
for int::range(shape.top_left.x, shape.top_left.x + shape.size.width) |x| {
|
||||
foreach x in range(shape.top_left.x, shape.top_left.x + shape.size.width) {
|
||||
self.add_pt(x, shape.top_left.y);
|
||||
self.add_pt(x, shape.top_left.y + shape.size.height - 1);
|
||||
}
|
||||
|
||||
// Add the left and right lines.
|
||||
for int::range(shape.top_left.y, shape.top_left.y + shape.size.height) |y|{
|
||||
foreach y in range(shape.top_left.y, shape.top_left.y + shape.size.height) {
|
||||
self.add_pt(shape.top_left.x, y);
|
||||
self.add_pt(shape.top_left.x + shape.size.width - 1, y);
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue