From d61338172fa110fcf9e5f2df0e1e83635d0fde3f Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Wed, 26 Nov 2014 10:10:52 -0500 Subject: Rewrite threading infrastructure, introducing `Thunk` to represent boxed `FnOnce` closures. --- src/libstd/sys/unix/process.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/libstd/sys') diff --git a/src/libstd/sys/unix/process.rs b/src/libstd/sys/unix/process.rs index dfbba0f335c..f71b34304ab 100644 --- a/src/libstd/sys/unix/process.rs +++ b/src/libstd/sys/unix/process.rs @@ -531,8 +531,11 @@ impl Process { } } -fn with_argv(prog: &CString, args: &[CString], - cb: proc(*const *const libc::c_char) -> T) -> T { +fn with_argv(prog: &CString, args: &[CString], + cb: F) + -> T + where F : FnOnce(*const *const libc::c_char) -> T +{ let mut ptrs: Vec<*const libc::c_char> = Vec::with_capacity(args.len()+1); // Convert the CStrings into an array of pointers. Note: the @@ -549,9 +552,12 @@ fn with_argv(prog: &CString, args: &[CString], cb(ptrs.as_ptr()) } -fn with_envp(env: Option<&collections::HashMap>, - cb: proc(*const c_void) -> T) -> T - where K: BytesContainer + Eq + Hash, V: BytesContainer +fn with_envp(env: Option<&collections::HashMap>, + cb: F) + -> T + where F : FnOnce(*const c_void) -> T, + K : BytesContainer + Eq + Hash, + V : BytesContainer { // On posixy systems we can pass a char** for envp, which is a // null-terminated array of "k=v\0" strings. Since we must create -- cgit 1.4.1-3-g733a5