std::process Rust · 常用路径
标准库的进程管理模块,可启动子进程、等待退出、获取输出或终止当前进程。
怎么用
use std::process::...;,用于进程管理
小例子
use std::process::Command;
let out = Command::new("rustc").arg("--version").output();
println!("{}", out.is_ok() || out.is_err());
运行结果
true
提醒:在 Windows 上调用 cmd 内置命令需用 cmd /c;output() 总是返回 Result
在代码里遇到不认识的词?打开代码点读机,点一下就懂 → ← Rust全部词条