Skip to content

Commit 151b7ed

Browse files
committed
libstd: Fix Win32 and other bustage.
1 parent 749ee53 commit 151b7ed

File tree

10 files changed

+41
-39
lines changed

10 files changed

+41
-39
lines changed

src/libstd/condition.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ This macro declares an inner module called `my_error` with one static variable,
3030
parameters are used for, an example usage of this condition would be:
3131
3232
```rust
33-
do my_error::cond.trap(|raised_int| {
33+
my_error::cond.trap(|raised_int| {
3434
3535
// the condition `my_error` was raised on, and the value it raised is stored
3636
// in `raised_int`. This closure must return a `~str` type (as specified in
3737
// the declaration of the condition
3838
if raised_int == 3 { ~"three" } else { ~"oh well" }
3939
40-
}).inside {
40+
}).inside(|| {
4141
4242
// The condition handler above is installed for the duration of this block.
4343
// That handler will override any previous handler, but the previous handler
@@ -50,7 +50,7 @@ do my_error::cond.trap(|raised_int| {
5050
println(my_error::cond.raise(3)); // prints "three"
5151
println(my_error::cond.raise(4)); // prints "oh well"
5252
53-
}
53+
})
5454
```
5555
5656
Condition handling is useful in cases where propagating errors is either to
@@ -176,9 +176,9 @@ impl<'self, T, U> Trap<'self, T, U> {
176176
/// ```rust
177177
/// condition! { my_error: int -> int; }
178178
///
179-
/// let result = do my_error::cond.trap(|error| error + 3).inside {
179+
/// let result = my_error::cond.trap(|error| error + 3).inside(|| {
180180
/// my_error::cond.raise(4)
181-
/// };
181+
/// });
182182
/// assert_eq!(result, 7);
183183
/// ```
184184
pub fn inside<V>(&self, inner: 'self || -> V) -> V {

src/libstd/gc.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,19 @@ mod tests {
6161
fn test_clone() {
6262
let x = Gc::new(RefCell::new(5));
6363
let y = x.clone();
64-
do x.borrow().with_mut |inner| {
64+
x.borrow().with_mut(|inner| {
6565
*inner = 20;
66-
}
66+
});
6767
assert_eq!(y.borrow().with(|x| *x), 20);
6868
}
6969

7070
#[test]
7171
fn test_deep_clone() {
7272
let x = Gc::new(RefCell::new(5));
7373
let y = x.deep_clone();
74-
do x.borrow().with_mut |inner| {
74+
x.borrow().with_mut(|inner| {
7575
*inner = 20;
76-
}
76+
});
7777
assert_eq!(y.borrow().with(|x| *x), 5);
7878
}
7979

src/libstd/io/native/file.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,9 @@ pub fn unlink(p: &CString) -> IoResult<()> {
576576
#[cfg(windows)]
577577
fn os_unlink(p: &CString) -> IoResult<()> {
578578
super::mkerr_winbool(unsafe {
579-
as_utf16_p(p.as_str().unwrap(), |buf| libc::DeleteFileW(buf));
579+
as_utf16_p(p.as_str().unwrap(), |buf| {
580+
libc::DeleteFileW(buf)
581+
})
580582
})
581583
}
582584

src/libstd/io/native/process.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ fn with_envp<T>(env: Option<~[(~str, ~str)]>, cb: |*mut c_void| -> T) -> T {
499499

500500
blk.push(0);
501501

502-
blk.as_imm_buf(|p, _len| unsafe { cb(cast::transmute(p)) });
502+
blk.as_imm_buf(|p, _len| unsafe { cb(cast::transmute(p)) })
503503
}
504504
_ => cb(ptr::mut_null())
505505
}

src/libstd/num/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ pub trait Unsigned: Num {}
104104
/// use num::Times;
105105
/// let ten = 10 as uint;
106106
/// let mut accum = 0;
107-
/// do ten.times { accum += 1; }
107+
/// ten.times(|| { accum += 1; })
108108
/// ```
109109
///
110110
pub trait Times {

src/libstd/num/uint.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,13 @@ impl num::Times for uint {
7777
#[inline]
7878
///
7979
/// A convenience form for basic repetition. Given a uint `x`,
80-
/// `do x.times { ... }` executes the given block x times.
80+
/// `x.times(|| { ... })` executes the given block x times.
8181
///
8282
/// Equivalent to `for uint::range(0, x) |_| { ... }`.
8383
///
8484
/// Not defined on all integer types to permit unambiguous
8585
/// use with integer literals of inferred integer-type as
86-
/// the self-value (eg. `do 100.times { ... }`).
86+
/// the self-value (eg. `100.times(|| { ... })`).
8787
///
8888
fn times(&self, it: ||) {
8989
let mut i = *self;

src/libstd/ops.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,8 +481,8 @@ mod bench {
481481

482482
#[bench]
483483
fn alloc_obj_with_dtor(bh: &mut BenchHarness) {
484-
do bh.iter {
484+
bh.iter(|| {
485485
HasDtor { x : 10 };
486-
}
486+
})
487487
}
488488
}

src/libstd/rand/os.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,9 @@ impl Rng for OSRng {
111111
pbBuffer: *mut BYTE);
112112
}
113113

114-
do v.as_mut_buf |ptr, len| {
114+
v.as_mut_buf(|ptr, len| {
115115
unsafe {rust_win32_rand_gen(self.hcryptprov, len as DWORD, ptr)}
116-
}
116+
})
117117
}
118118
}
119119

src/libstd/rt/args.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,16 +109,16 @@ mod imp {
109109

110110
fn with_lock<T>(f: || -> T) -> T {
111111
static mut lock: Mutex = MUTEX_INIT;
112-
do (|| {
112+
(|| {
113113
unsafe {
114114
lock.lock();
115115
f()
116116
}
117-
}).finally {
117+
}).finally(|| {
118118
unsafe {
119119
lock.unlock();
120120
}
121-
}
121+
})
122122
}
123123

124124
fn get_global_ptr() -> *mut Option<~~[~str]> {
@@ -127,9 +127,9 @@ mod imp {
127127

128128
// Copied from `os`.
129129
unsafe fn load_argc_and_argv(argc: int, argv: **u8) -> ~[~str] {
130-
do vec::from_fn(argc as uint) |i| {
130+
vec::from_fn(argc as uint, |i| {
131131
str::raw::from_c_str(*(argv as **libc::c_char).offset(i as int))
132-
}
132+
})
133133
}
134134

135135
#[cfg(test)]

src/libstd/vec.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3894,68 +3894,68 @@ mod bench {
38943894
#[bench]
38953895
fn push(bh: &mut BenchHarness) {
38963896
let mut vec: ~[uint] = ~[0u];
3897-
do bh.iter() {
3897+
bh.iter(|| {
38983898
vec.push(0);
3899-
}
3899+
})
39003900
}
39013901

39023902
#[bench]
39033903
fn starts_with_same_vector(bh: &mut BenchHarness) {
39043904
let vec: ~[uint] = vec::from_fn(100, |i| i);
3905-
do bh.iter() {
3905+
bh.iter(|| {
39063906
vec.starts_with(vec);
3907-
}
3907+
})
39083908
}
39093909

39103910
#[bench]
39113911
fn starts_with_single_element(bh: &mut BenchHarness) {
39123912
let vec: ~[uint] = ~[0u];
3913-
do bh.iter() {
3913+
bh.iter(|| {
39143914
vec.starts_with(vec);
3915-
}
3915+
})
39163916
}
39173917

39183918
#[bench]
39193919
fn starts_with_diff_one_element_at_end(bh: &mut BenchHarness) {
39203920
let vec: ~[uint] = vec::from_fn(100, |i| i);
39213921
let mut match_vec: ~[uint] = vec::from_fn(99, |i| i);
39223922
match_vec.push(0);
3923-
do bh.iter() {
3923+
bh.iter(|| {
39243924
vec.starts_with(match_vec);
3925-
}
3925+
})
39263926
}
39273927

39283928
#[bench]
39293929
fn ends_with_same_vector(bh: &mut BenchHarness) {
39303930
let vec: ~[uint] = vec::from_fn(100, |i| i);
3931-
do bh.iter() {
3931+
bh.iter(|| {
39323932
vec.ends_with(vec);
3933-
}
3933+
})
39343934
}
39353935

39363936
#[bench]
39373937
fn ends_with_single_element(bh: &mut BenchHarness) {
39383938
let vec: ~[uint] = ~[0u];
3939-
do bh.iter() {
3939+
bh.iter(|| {
39403940
vec.ends_with(vec);
3941-
}
3941+
})
39423942
}
39433943

39443944
#[bench]
39453945
fn ends_with_diff_one_element_at_beginning(bh: &mut BenchHarness) {
39463946
let vec: ~[uint] = vec::from_fn(100, |i| i);
39473947
let mut match_vec: ~[uint] = vec::from_fn(100, |i| i);
39483948
match_vec[0] = 200;
3949-
do bh.iter() {
3949+
bh.iter(|| {
39503950
vec.starts_with(match_vec);
3951-
}
3951+
})
39523952
}
39533953

39543954
#[bench]
39553955
fn contains_last_element(bh: &mut BenchHarness) {
39563956
let vec: ~[uint] = vec::from_fn(100, |i| i);
3957-
do bh.iter() {
3957+
bh.iter(|| {
39583958
vec.contains(&99u);
3959-
}
3959+
})
39603960
}
39613961
}

0 commit comments

Comments
 (0)