From cdbb3ca9b776b066e2c93acfb60da8537d2b1c9b Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Sun, 7 Dec 2014 14:15:25 -0500 Subject: libstd: use unboxed closures --- src/libstd/sys/windows/mod.rs | 2 +- src/libstd/sys/windows/process.rs | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'src/libstd/sys/windows') diff --git a/src/libstd/sys/windows/mod.rs b/src/libstd/sys/windows/mod.rs index 9fce308cb94..41361a0cde6 100644 --- a/src/libstd/sys/windows/mod.rs +++ b/src/libstd/sys/windows/mod.rs @@ -138,7 +138,7 @@ pub fn decode_error_detailed(errno: i32) -> IoError { } #[inline] -pub fn retry (f: || -> I) -> I { f() } // PR rust-lang/rust/#17020 +pub fn retry(f: F) -> I where F: FnOnce() -> I { f() } // PR rust-lang/rust/#17020 pub fn ms_to_timeval(ms: u64) -> libc::timeval { libc::timeval { diff --git a/src/libstd/sys/windows/process.rs b/src/libstd/sys/windows/process.rs index adbcff8a53f..356d6f02565 100644 --- a/src/libstd/sys/windows/process.rs +++ b/src/libstd/sys/windows/process.rs @@ -418,9 +418,8 @@ fn make_command_line(prog: &CString, args: &[CString]) -> String { } } -fn with_envp(env: Option<&collections::HashMap>, - cb: |*mut c_void| -> T) -> T - where K: BytesContainer + Eq + Hash, V: BytesContainer +fn with_envp(env: Option<&collections::HashMap>, cb: F) -> T where + K: BytesContainer + Eq + Hash, V: BytesContainer, F: FnOnce(*mut c_void) -> T, { // On Windows we pass an "environment block" which is not a char**, but // rather a concatenation of null-terminated k=v\0 sequences, with a final @@ -445,7 +444,9 @@ fn with_envp(env: Option<&collections::HashMap>, } } -fn with_dirp(d: Option<&CString>, cb: |*const u16| -> T) -> T { +fn with_dirp(d: Option<&CString>, cb: F) -> T where + F: FnOnce(*const u16) -> T, +{ match d { Some(dir) => { let dir_str = dir.as_str() -- cgit 1.4.1-3-g733a5