How can I convert a std::process::Command into a command line string?
问题 For example: let mut com = std::process::Command::new("ProgramA"); com.env("ENV_1", "VALUE_1") .arg("-a") .arg("foo") .arg("-b") .arg("--argument=bar"); // Get the command line string somehow here. com.output().unwrap(); This will spawn a process with this command line "ProgramA" -a foo -b "--argument=with space" associated with it. Is there a way to get this back out from the com object? 回答1: It turns out Command implements Debug ; this will give me the desired result: let answer = format!("