首页 > 解决方案 > 如何使用`std::io::Command`

问题描述

我正在尝试在 Rust 中执行以下代码:

use std::io::Command;

fn main() {
    let the_output = Command::new("ruby").arg(["-e", "puts 'raja'", "x"]).output()
}

但它抛出了这个错误:

error[E0432]: unresolved import `std::io::Command`
 --> src\main.rs:1:5
  |
1 | use std::io::Command;
  |     ^^^^^^^^^^^^^^^^ no `Command` in `io`

有人可以指导我如何将其导入use std::io::Command;我的程序吗?

标签: rust

解决方案


没有一个std::io::Command。你可能在想std::process::Command


推荐阅读