知识卡片

普通读书笔记卡 · 6075.c.1.m · 生成模型:未记录

工作区锁定外部依赖

理解等级:中级

共用 Cargo.lock 表示 Cargo 统一记录工作区的依赖解析结果。示例里 rand 先由一个成员使用,其他成员仍须在自己的清单声明后才能导入。成员约束允许时可共享解析版本,有冲突的版本约束时须按实际解析判断。

相关卡片 [[工作区统一构建协作]]

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    参考来源

    - 位置:《The Rust Programming Language(第2版)》第14章 深入 Cargo 与 Crates.io(来源项目 a19c7933-4eda-4176-aebd-30fe7e1ad292,`extracted/The Rust Programming Language(第2版)/_epub-src/c14.xhtml`,块 0168) - 结论依据:原文用一个成员导入 rand 失败的示例区分根锁文件与成员可用依赖。 - 原始内容: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: