Skip to content

Commit f865812

Browse files
committed
auto merge of #15566 : japaric/rust/command-clone, r=alexcrichton
Allows use cases like this one: ``` rust use std::io::Command; fn main() { let mut cmd = Command::new("ls"); cmd.arg("-l"); for &dir in ["a", "b", "c"].iter() { println!("{}", cmd.clone().arg(dir)); } } ``` Output: ``` ls '-l' 'a' ls '-l' 'b' ls '-l' 'c' ``` Without the `clone()`, you'll end up with: ``` ls '-l' 'a' ls '-l' 'a' 'b' ls '-l' 'a' 'b' 'c' ``` cc #15294
2 parents 6372915 + 6d50828 commit f865812

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/libstd/io/process.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ pub struct Process {
9494
///
9595
/// let output = process.stdout.get_mut_ref().read_to_end();
9696
/// ```
97+
#[deriving(Clone)]
9798
pub struct Command {
9899
// The internal data for the builder. Documented by the builder
99100
// methods below, and serialized into rt::rtio::ProcessConfig.
@@ -340,6 +341,7 @@ pub struct ProcessOutput {
340341
}
341342

342343
/// Describes what to do with a standard io stream for a child process.
344+
#[deriving(Clone)]
343345
pub enum StdioContainer {
344346
/// This stream will be ignored. This is the equivalent of attaching the
345347
/// stream to `/dev/null`

0 commit comments

Comments
 (0)