Skip to content

Commit 074b63a

Browse files
authored
Merge pull request #23 from mesalock-linux/master
Change with_stdin to &mut to fix #22
2 parents fdfbe66 + 30a3941 commit 074b63a

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/stdin.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,17 @@ pub trait CommandStdInExt {
2121
/// use std::process::Command;
2222
///
2323
/// Command::new("cat")
24+
/// .arg("-A")
2425
/// .with_stdin("42")
2526
/// .unwrap();
2627
/// ```
27-
fn with_stdin<S>(self, buffer: S) -> StdInCommand
28+
fn with_stdin<S>(&mut self, buffer: S) -> StdInCommand
2829
where
2930
S: Into<Vec<u8>>;
3031
}
3132

3233
impl CommandStdInExt for process::Command {
33-
fn with_stdin<S>(self, buffer: S) -> StdInCommand
34+
fn with_stdin<S>(&mut self, buffer: S) -> StdInCommand
3435
where
3536
S: Into<Vec<u8>>,
3637
{
@@ -57,12 +58,12 @@ impl CommandStdInExt for process::Command {
5758
/// .unwrap();
5859
/// ```
5960
#[derive(Debug)]
60-
pub struct StdInCommand {
61-
cmd: process::Command,
61+
pub struct StdInCommand<'a> {
62+
cmd: &'a mut process::Command,
6263
stdin: Vec<u8>,
6364
}
6465

65-
impl StdInCommand {
66+
impl<'a> StdInCommand<'a> {
6667
/// Executes the command as a child process, waiting for it to finish and collecting all of its
6768
/// output.
6869
///
@@ -97,7 +98,7 @@ impl StdInCommand {
9798
}
9899
}
99100

100-
impl<'c> OutputOkExt for &'c mut StdInCommand {
101+
impl<'c, 'a> OutputOkExt for &'c mut StdInCommand<'a> {
101102
fn ok(self) -> OutputResult {
102103
let output = self.output().map_err(OutputError::with_cause)?;
103104
if output.status.success() {
@@ -123,7 +124,7 @@ impl<'c> OutputOkExt for &'c mut StdInCommand {
123124
}
124125
}
125126

126-
impl<'c> OutputAssertExt for &'c mut StdInCommand {
127+
impl<'c> OutputAssertExt for &'c mut StdInCommand<'c> {
127128
fn assert(self) -> Assert {
128129
let output = self.output().unwrap();
129130
Assert::new(output)

0 commit comments

Comments
 (0)