在 Rust 存储库中,有一个名称中带有破折号“-”的包,我如何在 Rust 代码中“使用”?

问题描述 投票:0回答:1

我想在 Rust 代码中使用异步进程板条箱/包。

https://github.com/smol-rs/async-process.git.

在自述文件中,他们在他们的页面上说可以将其放入我的项目 Cargo.toml 中:

[dependencies]
async_process = "2.0.1" # this cant find it.
async-process = "2.0.1" # this will find it, but name can't be used in code.

在我的 Rust 代码中为:

use async_process::Command; // this fails to find the "crate"

// this is a syntax error as "-" is notvalid in a use path
use async-process::Command  

这行不通。 我还尝试了 rust-lang.org 上他们所说的各种变体。

https://doc.rust-lang.org/cargo/reference/specifying-dependency.html?highlight=rename,depende#renaming-dependency-in-cargotoml

这应该如何运作?

rust rust-cargo
1个回答
0
投票

在cargo.toml中,使用

async-process = "2.0.1"

在代码中,使用下划线。

use async_process::Command;
© www.soinside.com 2019 - 2024. All rights reserved.