Skip to content

Commit 1c49fd2

Browse files
committed
Clean up Cmds by eliminating unnecessary Option
1 parent 888b687 commit 1c49fd2

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/process.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use std::ffi::{OsStr, OsString};
1111
use std::fmt;
1212
use std::fs::{File, OpenOptions};
1313
use std::io::{Error, ErrorKind, Result};
14+
use std::mem::take;
1415
use std::path::{Path, PathBuf};
1516
use std::process::Command;
1617
use std::sync::Mutex;
@@ -160,7 +161,7 @@ impl GroupCmds {
160161
#[doc(hidden)]
161162
#[derive(Default)]
162163
pub struct Cmds {
163-
cmds: Vec<Option<Cmd>>,
164+
cmds: Vec<Cmd>,
164165
full_cmds: String,
165166
ignore_error: bool,
166167
file: String,
@@ -188,7 +189,7 @@ impl Cmds {
188189
);
189190
}
190191
}
191-
self.cmds.push(Some(cmd));
192+
self.cmds.push(cmd);
192193
self
193194
}
194195

@@ -204,8 +205,7 @@ impl Cmds {
204205
let mut children: Vec<CmdChild> = Vec::new();
205206
let len = self.cmds.len();
206207
let mut prev_pipe_in = None;
207-
for (i, cmd_opt) in self.cmds.iter_mut().enumerate() {
208-
let mut cmd = cmd_opt.take().unwrap();
208+
for (i, mut cmd) in take(&mut self.cmds).into_iter().enumerate() {
209209
if i != len - 1 {
210210
// not the last, update redirects
211211
let (pipe_reader, pipe_writer) =

0 commit comments

Comments
 (0)