File tree Expand file tree Collapse file tree 4 files changed +7
-5
lines changed Expand file tree Collapse file tree 4 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -334,7 +334,7 @@ pub fn set_stderr(stderr: Box<Writer + Send>) -> Option<Box<Writer + Send>> {
334
334
// // io1 aliases io2
335
335
// })
336
336
// })
337
- fn with_task_stdout ( f: | & mut Writer | -> IoResult < ( ) > ) {
337
+ fn with_task_stdout < F > ( f : F ) where F : FnOnce ( & mut Writer ) -> IoResult < ( ) > {
338
338
let mut my_stdout = LOCAL_STDOUT . with ( |slot| {
339
339
slot. borrow_mut ( ) . take ( )
340
340
} ) . unwrap_or_else ( || {
Original file line number Diff line number Diff line change @@ -174,7 +174,7 @@ impl Task {
174
174
///
175
175
/// It is invalid to call this function with a thread that has been previously
176
176
/// destroyed via a failed call to `run`.
177
- pub fn run ( mut self : Box < Task > , f: || ) -> Box < Task > {
177
+ pub fn run < F > ( mut self : Box < Task > , f : F ) -> Box < Task > where F : FnOnce ( ) {
178
178
assert ! ( !self . is_destroyed( ) , "cannot re-use a destroyed thread" ) ;
179
179
180
180
// First, make sure that no one else is in TLS. This does not allow
Original file line number Diff line number Diff line change @@ -26,13 +26,13 @@ struct ThreadInfo {
26
26
thread_local ! { static THREAD_INFO : RefCell <Option <ThreadInfo >> = RefCell :: new( None ) }
27
27
28
28
impl ThreadInfo {
29
- fn with < R > ( f: | & mut ThreadInfo | -> R ) -> R {
29
+ fn with < R , F > ( f : F ) -> R where F : FnOnce ( & mut ThreadInfo ) -> R {
30
30
if THREAD_INFO . destroyed ( ) {
31
31
panic ! ( "Use of std::thread::Thread::current() is not possible after \
32
32
the thread's local data has been destroyed") ;
33
33
}
34
34
35
- THREAD_INFO . with ( |c| {
35
+ THREAD_INFO . with ( move |c| {
36
36
if c. borrow ( ) . is_none ( ) {
37
37
* c. borrow_mut ( ) = Some ( ThreadInfo {
38
38
stack_bounds : ( 0 , 0 ) ,
Original file line number Diff line number Diff line change @@ -124,7 +124,9 @@ pub unsafe fn pipe() -> IoResult<(FileDesc, FileDesc)> {
124
124
}
125
125
}
126
126
127
- pub fn fill_utf16_buf_and_decode ( f : |* mut u16 , DWORD | -> DWORD ) -> Option < String > {
127
+ pub fn fill_utf16_buf_and_decode < F > ( mut f : F ) -> Option < String > where
128
+ F : FnMut ( * mut u16 , DWORD ) -> DWORD ,
129
+ {
128
130
unsafe {
129
131
let mut n = TMPBUF_SZ as DWORD ;
130
132
let mut res = None ;
You can’t perform that action at this time.
0 commit comments