rust - 如何使用 `std::io::Command`

标签 rust

我正在尝试在 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; 导入我的程序吗?

最佳答案

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

关于rust - 如何使用 `std::io::Command`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55662435/

相关文章:

generics - 错误的类型参数 : expected 1 but found 0

recursion - 树中节点的递归搜索

python - 在 Python 中取消引用 FFI 指针以获取底层数组

console - 从 Visual Studio Code 中的控制台输出跳转到源代码

rust - 令人困惑的无法到达的模式错误

image - 如何在 Rust 中保存 PNG 图像?

rust - 将切片过滤成向量

rust - 在 actix-web 服务器和异步闭包之间共享状态

rust - 是否可以从另一个成员闭包中调用一个成员闭包?

parsing - 在 Rust 中返回多种类型的惯用方式