diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2014-11-26 10:10:52 -0500 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2014-12-14 04:21:56 -0500 |
| commit | d61338172fa110fcf9e5f2df0e1e83635d0fde3f (patch) | |
| tree | 5a022b681067ce30acf73e06aef9896f3cfd4be2 /src/libstd/sys | |
| parent | 10ac5b72f1974775bed499105c2a3cf18da98f32 (diff) | |
| download | rust-d61338172fa110fcf9e5f2df0e1e83635d0fde3f.tar.gz rust-d61338172fa110fcf9e5f2df0e1e83635d0fde3f.zip | |
Rewrite threading infrastructure, introducing `Thunk` to represent
boxed `FnOnce` closures.
Diffstat (limited to 'src/libstd/sys')
| -rw-r--r-- | src/libstd/sys/unix/process.rs | 16 |
1 files changed, 11 insertions, 5 deletions
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<T>(prog: &CString, args: &[CString], - cb: proc(*const *const libc::c_char) -> T) -> T { +fn with_argv<T,F>(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<T>(prog: &CString, args: &[CString], cb(ptrs.as_ptr()) } -fn with_envp<K, V, T>(env: Option<&collections::HashMap<K, V>>, - cb: proc(*const c_void) -> T) -> T - where K: BytesContainer + Eq + Hash, V: BytesContainer +fn with_envp<K,V,T,F>(env: Option<&collections::HashMap<K, V>>, + 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 |
