File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed
Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -1053,7 +1053,16 @@ impl Cmd {
10531053 } )
10541054 }
10551055
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 {
10571066 let mut result = Command :: new ( & self . prog ) ;
10581067 result. current_dir ( & self . sh . cwd ) ;
10591068 result. args ( & self . args ) ;
Original file line number Diff line number Diff line change @@ -35,7 +35,9 @@ fn smoke() {
3535#[ test]
3636fn into_command ( ) {
3737 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 ( ) ;
3941}
4042
4143#[ test]
You can’t perform that action at this time.
0 commit comments