File tree 2 files changed +13
-2
lines changed
2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -1053,7 +1053,16 @@ impl Cmd {
1053
1053
} )
1054
1054
}
1055
1055
1056
- fn to_command ( & self ) -> Command {
1056
+ /// Constructs a [`std::process::Command`] for the same command as `self`.
1057
+ ///
1058
+ /// The returned command will invoke the same program from the same working
1059
+ /// directory and with the same environment as `self`. If the command was
1060
+ /// set to [`ignore_stdout`](Cmd::ignore_stdout) or [`ignore_stderr`](Cmd::ignore_stderr),
1061
+ /// this will apply to the returned command as well.
1062
+ ///
1063
+ /// Other builder methods have no effect on the command returned since they
1064
+ /// control how the command is run, but this method does not yet execute the command.
1065
+ pub fn to_command ( & self ) -> Command {
1057
1066
let mut result = Command :: new ( & self . prog ) ;
1058
1067
result. current_dir ( & self . sh . cwd ) ;
1059
1068
result. args ( & self . args ) ;
Original file line number Diff line number Diff line change @@ -35,7 +35,9 @@ fn smoke() {
35
35
#[ test]
36
36
fn into_command ( ) {
37
37
let sh = setup ( ) ;
38
- let _: std:: process:: Command = cmd ! ( sh, "git branch" ) . into ( ) ;
38
+ let cmd = cmd ! ( sh, "git branch" ) ;
39
+ let _ = cmd. to_command ( ) ;
40
+ let _: std:: process:: Command = cmd. into ( ) ;
39
41
}
40
42
41
43
#[ test]
You can’t perform that action at this time.
0 commit comments