Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

with_stdin will take the ownership of command #22

Closed
mssun opened this issue Jul 13, 2018 · 6 comments
Closed

with_stdin will take the ownership of command #22

mssun opened this issue Jul 13, 2018 · 6 comments
Labels
breaking-change enhancement Improve the expected

Comments

@mssun
Copy link
Contributor

mssun commented Jul 13, 2018

The with_stdin will take the ownership of command. Therefore you cannot write chained functions like this:

Command::new("cat")
    .arg("-A")
    .with_stdin("42")
    .assert()
    .success();

Error:

error[E0507]: cannot move out of borrowed content
  --> /xxx.rs:43:5
   |
43 | /     Command::new("cat")
44 | |         .arg("-A")
   | |__________________^ cannot move out of borrowed content
@epage
Copy link
Contributor

epage commented Jul 13, 2018

Since spawn takes in a &mut, I could probably loosen this requirement to &mut.

@epage epage added enhancement Improve the expected breaking-change labels Jul 13, 2018
@mssun
Copy link
Contributor Author

mssun commented Jul 13, 2018

Good, thanks.

I'm trying to use assert-cmd for our integration tests: mesalock-linux/mesabox#24.

It will be very helpful if this issue can be quickly fixed. Thank you for the amazing project.

@epage epage closed this as completed in 474f868 Jul 13, 2018
epage added a commit that referenced this issue Jul 13, 2018
Change with_stdin to &mut to fix #22
@epage
Copy link
Contributor

epage commented Jul 13, 2018

Since this was a breaking change, I'm publishing it as v0.5.0 right now.

Did you test your conversion with #23? Should have probably checked with that first in case you find more issues :)

@mssun
Copy link
Contributor Author

mssun commented Jul 13, 2018

It works fine for my current usage.

The only concern is that with_stdin have to be the last function before assert since it returns StdInCommand instead of Command.

@epage
Copy link
Contributor

epage commented Jul 13, 2018

Yup, didn't have an idea for a better way of doing that.

@mssun
Copy link
Contributor Author

mssun commented Jul 13, 2018

Thanks anyway. I probably will come up some other features or bugs later during my refactoring :)

epage added a commit to epage/assert_cmd that referenced this issue Sep 27, 2024
…rmat-args

Have clippy warn about uninlined format arguments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change enhancement Improve the expected
Projects
None yet
Development

No branches or pull requests

2 participants