Skip to content

Commit 371f04d

Browse files
author
Jorge Aparicio
committed
std: unbox closures used in function arguments
1 parent a17c2b6 commit 371f04d

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

src/libstd/io/stdio.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ pub fn set_stderr(stderr: Box<Writer + Send>) -> Option<Box<Writer + Send>> {
334334
// // io1 aliases io2
335335
// })
336336
// })
337-
fn with_task_stdout(f: |&mut Writer| -> IoResult<()>) {
337+
fn with_task_stdout<F>(f: F) where F: FnOnce(&mut Writer) -> IoResult<()> {
338338
let mut my_stdout = LOCAL_STDOUT.with(|slot| {
339339
slot.borrow_mut().take()
340340
}).unwrap_or_else(|| {

src/libstd/rt/task.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ impl Task {
174174
///
175175
/// It is invalid to call this function with a thread that has been previously
176176
/// 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() {
178178
assert!(!self.is_destroyed(), "cannot re-use a destroyed thread");
179179

180180
// First, make sure that no one else is in TLS. This does not allow

src/libstd/sys/common/thread_info.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ struct ThreadInfo {
2626
thread_local! { static THREAD_INFO: RefCell<Option<ThreadInfo>> = RefCell::new(None) }
2727

2828
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 {
3030
if THREAD_INFO.destroyed() {
3131
panic!("Use of std::thread::Thread::current() is not possible after \
3232
the thread's local data has been destroyed");
3333
}
3434

35-
THREAD_INFO.with(|c| {
35+
THREAD_INFO.with(move |c| {
3636
if c.borrow().is_none() {
3737
*c.borrow_mut() = Some(ThreadInfo {
3838
stack_bounds: (0, 0),

src/libstd/sys/windows/os.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ pub unsafe fn pipe() -> IoResult<(FileDesc, FileDesc)> {
124124
}
125125
}
126126

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+
{
128130
unsafe {
129131
let mut n = TMPBUF_SZ as DWORD;
130132
let mut res = None;

0 commit comments

Comments
 (0)