使用嵌套 Cargo.toml 项目的 Rust 子包

Using Rust subpackage of nested Cargo.toml project

我想使用 this subpackage of this main git repository.

[dependency]
substrate-test-runtime-client = [git = "https://github.com/paritytech/substrate.git", branch = "master"]

以上 Cargo.toml 语法无法解决问题。我是 Rust 新手,请告诉我如何提取、编译和使用 umbrella 包的子包。

你走在正确的轨道上。您需要使用大括号来指定内联 TOML table.

因此,要么将以下内容添加到您的 Cargo.toml 文件中。

[dependencies]
substrate-test-runtime-client = { git = "https://github.com/paritytech/substrate.git", branch = "master" }

或者使用等效的

[dependencies.substrate-test-runtime-client]
git = "https://github.com/paritytech/substrate.git"
branch = "master"

Cargo 将爬取下载的存储库以查找名为 substrate-test-runtime-client 的包。参见 here