Skip to content

Commit 82b2455

Browse files
committed
auto merge of #8190 : thestinger/rust/for, r=thestinger
2 parents 479809a + 94f1a5d commit 82b2455

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+560
-499
lines changed

doc/tutorial-tasks.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ an intermediate generation has already exited:
548548
~~~
549549
# use std::task;
550550
# fn sleep_forever() { loop { task::yield() } }
551-
# fn wait_for_a_while() { for 1000.times { task::yield() } }
551+
# fn wait_for_a_while() { do 1000.times { task::yield() } }
552552
# do task::try::<int> {
553553
do task::spawn_supervised {
554554
do task::spawn_supervised {
@@ -567,7 +567,7 @@ other at all, using `task::spawn_unlinked` for _isolated failure_.
567567
~~~
568568
# use std::task;
569569
# fn random() -> uint { 100 }
570-
# fn sleep_for(i: uint) { for i.times { task::yield() } }
570+
# fn sleep_for(i: uint) { do i.times { task::yield() } }
571571
# do task::try::<()> {
572572
let (time1, time2) = (random(), random());
573573
do task::spawn_unlinked {

doc/tutorial.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1899,7 +1899,7 @@ struct TimeBomb {
18991899
19001900
impl Drop for TimeBomb {
19011901
fn drop(&self) {
1902-
for self.explosivity.times {
1902+
do self.explosivity.times {
19031903
println("blam!");
19041904
}
19051905
}

src/libextra/arc.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* let numbers=vec::from_fn(100, |ind| (ind as float)*rand::random());
2424
* let shared_numbers=arc::Arc::new(numbers);
2525
*
26-
* for 10.times {
26+
* do 10.times {
2727
* let (port, chan) = stream();
2828
* chan.send(shared_numbers.clone());
2929
*
@@ -761,7 +761,7 @@ mod tests {
761761
762762
do task::spawn || {
763763
do arc2.write |num| {
764-
for 10.times {
764+
do 10.times {
765765
let tmp = *num;
766766
*num = -1;
767767
task::yield();
@@ -773,7 +773,7 @@ mod tests {
773773
774774
// Readers try to catch the writer in the act
775775
let mut children = ~[];
776-
for 5.times {
776+
do 5.times {
777777
let arc3 = (*arc).clone();
778778
let mut builder = task::task();
779779
builder.future_result(|r| children.push(r));
@@ -807,7 +807,7 @@ mod tests {
807807
808808
// Reader tasks
809809
let mut reader_convos = ~[];
810-
for 10.times {
810+
do 10.times {
811811
let ((rp1,rc1),(rp2,rc2)) = (comm::stream(),comm::stream());
812812
reader_convos.push((rc1, rp2));
813813
let arcn = (*arc).clone();
@@ -921,7 +921,7 @@ mod tests {
921921
do read_mode.read |state| {
922922
// if writer mistakenly got in, make sure it mutates state
923923
// before we assert on it
924-
for 5.times { task::yield(); }
924+
do 5.times { task::yield(); }
925925
// make sure writer didn't get in.
926926
assert!(*state);
927927
}
@@ -933,6 +933,6 @@ mod tests {
933933
// helped to expose the race nearly 100% of the time... but adding
934934
// yields in the intuitively-right locations made it even less likely,
935935
// and I wasn't sure why :( . This is a mediocre "next best" option.
936-
for 8.times { test_rw_write_cond_downgrade_read_race_helper() }
936+
do 8.times { test_rw_write_cond_downgrade_read_race_helper() }
937937
}
938938
}

src/libextra/arena.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,12 @@ impl Drop for Arena {
7272
fn drop(&self) {
7373
unsafe {
7474
destroy_chunk(&self.head);
75-
for self.chunks.each |chunk| {
75+
do self.chunks.each |chunk| {
7676
if !chunk.is_pod {
7777
destroy_chunk(chunk);
7878
}
79-
}
79+
true
80+
};
8081
}
8182
}
8283
}

src/libextra/base64.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -358,9 +358,9 @@ mod test {
358358
use std::rand::{task_rng, random, RngUtil};
359359
use std::vec;
360360
361-
for 1000.times {
361+
do 1000.times {
362362
let v: ~[u8] = do vec::build |push| {
363-
for task_rng().gen_uint_range(1, 100).times {
363+
do task_rng().gen_uint_range(1, 100).times {
364364
push(random());
365365
}
366366
};
@@ -389,4 +389,4 @@ mod test {
389389
bh.bytes = b.len() as u64;
390390
}
391391

392-
}
392+
}

0 commit comments

Comments
 (0)