about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-07-10 09:16:29 +0000
committerbors <bors@rust-lang.org>2014-07-10 09:16:29 +0000
commitf8658124512bd06398908f989c9cc9fa05cf43f0 (patch)
tree9c2cc1f0b2a53f3c569bf6f973dc74fe03154575 /src/libstd
parent6372915a78a12adfbc327aba87225988ae03e7f9 (diff)
parent6d50828fdbf6eed62a8f22a52d81ecb4c5e98690 (diff)
downloadrust-f8658124512bd06398908f989c9cc9fa05cf43f0.tar.gz
rust-f8658124512bd06398908f989c9cc9fa05cf43f0.zip
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
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/io/process.rs2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/libstd/io/process.rs b/src/libstd/io/process.rs
index 8f1046b62fd..d781c414d08 100644
--- a/src/libstd/io/process.rs
+++ b/src/libstd/io/process.rs
@@ -94,6 +94,7 @@ pub struct Process {
 ///
 /// let output = process.stdout.get_mut_ref().read_to_end();
 /// ```
+#[deriving(Clone)]
 pub struct Command {
     // The internal data for the builder. Documented by the builder
     // methods below, and serialized into rt::rtio::ProcessConfig.
@@ -340,6 +341,7 @@ pub struct ProcessOutput {
 }
 
 /// Describes what to do with a standard io stream for a child process.
+#[deriving(Clone)]
 pub enum StdioContainer {
     /// This stream will be ignored. This is the equivalent of attaching the
     /// stream to `/dev/null`