← 返回卡片

原书出处

The Rust Programming Language(第2版)

14 深入 Cargo 与 Crates.io Depending on an External Package in a Workspace

第 2 版 · 核验版本的摘录快照 · 导入于 2026-11-24T14:01:16.971Z

The top-level Cargo.lock now contains information about the dependency of add_one on rand. However, even though rand is used somewhere in the workspace, we can’t use it in other crates in the workspace unless we add rand to their Cargo.toml files as well. For example, if we add use rand; to the adder/src/main.rs file for the adder package, we’ll get an error:

此预览只包含定位所需的摘录和上下文。

原书定位详情

来源:a19c7933-4eda-4176-aebd-30fe7e1ad292

正文位置:extracted/The Rust Programming Language(第2版)/_epub-src/c14.xhtml

EPUB SHA-256:610e9a4ca266a389faba5ffed033dc4bcae1c910c6259ea8ab73a6e93fbb9374