提交 2d76c94d 编写于 作者: J Jorge Aparicio

s/while let/for/g now that #21245 has been fixed

上级 c013a018
......@@ -104,9 +104,7 @@
fn reverse_bits(byte: u8) -> u8 {
let mut result = 0;
// FIXME(#21245) use a for loop
let mut iter = 0..u8::BITS;
while let Some(i) = iter.next() {
for i in 0..u8::BITS {
result |= ((byte >> i) & 1) << (u8::BITS - 1 - i);
}
result
......
......@@ -1793,9 +1793,7 @@ fn bench_new(b: &mut test::Bencher) {
fn bench_push_back_100(b: &mut test::Bencher) {
let mut deq = RingBuf::with_capacity(101);
b.iter(|| {
// FIXME(#21245) use a for loop
let mut iter = 0i..100;
while let Some(i) = iter.next() {
for i in 0i..100 {
deq.push_back(i);
}
deq.head = 0;
......@@ -1807,9 +1805,7 @@ fn bench_push_back_100(b: &mut test::Bencher) {
fn bench_push_front_100(b: &mut test::Bencher) {
let mut deq = RingBuf::with_capacity(101);
b.iter(|| {
// FIXME(#21245) use a for loop
let mut iter = 0i..100;
while let Some(i) = iter.next() {
for i in 0i..100 {
deq.push_front(i);
}
deq.head = 0;
......
......@@ -1567,9 +1567,7 @@ fn drop(&mut self) {
// zeroed (when moving out, because of #[unsafe_no_drop_flag]).
if self.cap != 0 {
unsafe {
// FIXME(#21245) use a for loop
let mut iter = self.iter();
while let Some(x) = iter.next() {
for x in self.iter() {
ptr::read(x);
}
dealloc(*self.ptr, self.cap)
......
......@@ -352,9 +352,7 @@ fn each_bit<F>(&self, words: &[uint], mut f: F) -> bool where
for (word_index, &word) in words.iter().enumerate() {
if word != 0 {
let base_index = word_index * uint::BITS;
// FIXME(#21245) use a for loop
let mut iter = 0u..uint::BITS;
while let Some(offset) = iter.next() {
for offset in 0u..uint::BITS {
let bit = 1 << offset;
if (word & bit) != 0 {
// NB: we round up the total number of bits
......
......@@ -148,9 +148,7 @@ impl<
fn decode<D: Decoder>(d: &mut D) -> Result<EnumSet<T>, D::Error> {
let bits = try!(d.read_uint());
let mut set = EnumSet::new();
// FIXME(#21245) use a for loop
let mut iter = 0..uint::BITS;
while let Some(bit) = iter.next() {
for bit in 0..uint::BITS {
if bits & (1 << bit) != 0 {
set.insert(CLike::from_uint(1 << bit));
}
......
......@@ -232,10 +232,7 @@ pub fn escape_default<F>(c: u8, mut f: F) where
_ => {
f(b'\\');
f(b'x');
// FIXME(#21245) use a for loop
let arr = [4u, 0u];
let mut iter = arr.iter();
while let ::option::Option::Some(&offset) = ::iter::Iterator::next(&mut iter) {
for &offset in [4u, 0u].iter() {
match ((c as i32) >> offset) & 0xf {
i @ 0 ... 9 => f(b'0' + (i as u8)),
i => f(b'a' + (i as u8 - 10)),
......
......@@ -404,9 +404,7 @@ fn test_os_rng_tasks() {
}
// start all the tasks
// FIXME(#21245) use a for loop
let mut iter = txs.iter();
while let Some(tx) = iter.next() {
for tx in txs.iter() {
tx.send(()).unwrap();
}
}
......
......@@ -1476,9 +1476,7 @@ fn test_recv_iter_break() {
let _t = Thread::spawn(move|| {
let mut count = 0;
// FIXME(#21245) use a for loop
let mut iter = rx.iter();
while let Some(x) = iter.next() {
for x in rx.iter() {
if count >= 3 {
break;
} else {
......@@ -1942,9 +1940,7 @@ fn test_recv_iter_break() {
let _t = Thread::spawn(move|| {
let mut count = 0;
// FIXME(#21245) use a for loop
let mut iter = rx.iter();
while let Some(x) = iter.next() {
for x in rx.iter() {
if count >= 3 {
break;
} else {
......
......@@ -185,9 +185,7 @@ fn test() {
let tx = tx.clone();
let q = q.clone();
Thread::spawn(move|| {
// FIXME(#21245) use a for loop
let mut iter = 0..nmsgs;
while let Some(i) = iter.next() {
for i in 0..nmsgs {
q.push(i);
}
tx.send(()).unwrap();
......
......@@ -37,14 +37,10 @@ pub trait MoveMap<T> {
impl<T> MoveMap<T> for Vec<T> {
fn move_map<F>(mut self, mut f: F) -> Vec<T> where F: FnMut(T) -> T {
// FIXME(#21245) use a for loop
{
let mut iter = self.iter_mut();
while let Some(p) = iter.next() {
unsafe {
// FIXME(#5016) this shouldn't need to zero to be safe.
ptr::write(p, f(ptr::read_and_zero(p)));
}
for p in self.iter_mut() {
unsafe {
// FIXME(#5016) this shouldn't need to zero to be safe.
ptr::write(p, f(ptr::read_and_zero(p)));
}
}
self
......
......@@ -133,9 +133,7 @@ fn mandelbrot<W: old_io::Writer>(w: uint, mut out: W) -> old_io::IoResult<()> {
(i + 1) * chunk_size
};
// FIXME(#21245) use a for loop
let mut iter = vec_init_i[start..end].iter();
while let Some(&init_i) = iter.next() {
for &init_i in vec_init_i[start..end].iter() {
write_line(init_i, init_r_slice, &mut res);
}
......@@ -144,9 +142,7 @@ fn mandelbrot<W: old_io::Writer>(w: uint, mut out: W) -> old_io::IoResult<()> {
}).collect::<Vec<_>>();
try!(writeln!(&mut out as &mut Writer, "P4\n{} {}", w, h));
// FIXME(#21245) use a for loop
let mut iter = data.into_iter();
while let Some(res) = iter.next() {
for res in data.into_iter() {
try!(out.write(res.join().ok().unwrap().as_slice()));
}
out.flush()
......
......@@ -180,9 +180,7 @@ fn make_masks() -> Vec<Vec<Vec<u64> > > {
// all unused piece can be placed on the board.
fn is_board_unfeasible(board: u64, masks: &Vec<Vec<Vec<u64>>>) -> bool {
let mut coverable = board;
// FIXME(#21245) use a for loop
let mut iter = masks.iter().enumerate();
while let Some((i, masks_at)) = iter.next() {
for (i, masks_at) in masks.iter().enumerate() {
if board & 1 << i != 0 { continue; }
for (cur_id, pos_masks) in masks_at.iter().enumerate() {
if board & 1 << (50 + cur_id) != 0 { continue; }
......@@ -224,9 +222,7 @@ fn to_vec(raw_sol: &List<u64>) -> Vec<u8> {
let mut sol = repeat('.' as u8).take(50).collect::<Vec<_>>();
for &m in raw_sol.iter() {
let id = '0' as u8 + get_id(m);
// FIXME(#21245) use a for loop
let mut iter = 0u..50;
while let Some(i) = iter.next() {
for i in 0u..50 {
if m & 1 << i != 0 {
sol[i] = id;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册