Skip to content

Commit 2fd13d4

Browse files
authored
1 parent 71f6ee9 commit 2fd13d4

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/spawn.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -351,12 +351,11 @@ impl Drop for PosixSpawnFileActions {
351351
// SAFETY:
352352
// It is safe to add the mutability in types as implementations won't mutable them.
353353
unsafe fn to_exec_array<S: AsRef<CStr>>(args: &[S]) -> Vec<*mut libc::c_char> {
354-
let mut v: Vec<*mut libc::c_char> = args
355-
.iter()
354+
use std::iter::once;
355+
args.iter()
356356
.map(|s| s.as_ref().as_ptr().cast_mut())
357-
.collect();
358-
v.push(std::ptr::null_mut());
359-
v
357+
.chain(once(std::ptr::null_mut()))
358+
.collect()
360359
}
361360

362361
/// Create a new child process from the specified process image. See

0 commit comments

Comments
 (0)