Skip to content

Commit

Permalink
Change with_stdin to &mut to fix #22
Browse files Browse the repository at this point in the history
  • Loading branch information
Mingshen Sun committed Jul 13, 2018
1 parent fdfbe66 commit 474f868
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/stdin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ pub trait CommandStdInExt {
/// .with_stdin("42")
/// .unwrap();
/// ```
fn with_stdin<S>(self, buffer: S) -> StdInCommand
fn with_stdin<S>(&mut self, buffer: S) -> StdInCommand
where
S: Into<Vec<u8>>;
}

impl CommandStdInExt for process::Command {
fn with_stdin<S>(self, buffer: S) -> StdInCommand
fn with_stdin<S>(&mut self, buffer: S) -> StdInCommand
where
S: Into<Vec<u8>>,
{
Expand All @@ -57,12 +57,12 @@ impl CommandStdInExt for process::Command {
/// .unwrap();
/// ```
#[derive(Debug)]
pub struct StdInCommand {
cmd: process::Command,
pub struct StdInCommand<'a> {
cmd: &'a mut process::Command,
stdin: Vec<u8>,
}

impl StdInCommand {
impl<'a> StdInCommand<'a> {
/// Executes the command as a child process, waiting for it to finish and collecting all of its
/// output.
///
Expand Down Expand Up @@ -97,7 +97,7 @@ impl StdInCommand {
}
}

impl<'c> OutputOkExt for &'c mut StdInCommand {
impl<'c, 'a> OutputOkExt for &'c mut StdInCommand<'a> {
fn ok(self) -> OutputResult {
let output = self.output().map_err(OutputError::with_cause)?;
if output.status.success() {
Expand All @@ -123,7 +123,7 @@ impl<'c> OutputOkExt for &'c mut StdInCommand {
}
}

impl<'c> OutputAssertExt for &'c mut StdInCommand {
impl<'c> OutputAssertExt for &'c mut StdInCommand<'c> {
fn assert(self) -> Assert {
let output = self.output().unwrap();
Assert::new(output)
Expand Down

0 comments on commit 474f868

Please sign in to comment.