← 返回刚才阅读的位置

知识卡片

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

锁文件固定依赖解析

理解等级:中级

Cargo.toml 给出允许的版本集合。书中 0.8.5 对应从 0.8.5 到 0.9.0 之前的范围。Cargo 还要解析传递依赖,Cargo.lock 保存这次的具体选择。主动更新会在约束内改变选定版本,跨不兼容版本需先改清单。锁文件只固定依赖解析,构建产物还受工具链和平台等条件影响。

相关卡片 [[Cargo统一工程入口]]

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • 猜数字游戏 Generating a Secret Number · 查看原书依据

      When you build a project for the first time, Cargo figures out all the versions of the dependencies that fit the criteria and then writes them to the Cargo.lock file. When you build your project in the future, Cargo will see that the Cargo.lock file exists and will use the versions specified there rather than doing all the work of figuring out versions again.

    参考来源

    - 位置:《The Rust Programming Language(第2版)》第02章 猜数字游戏(来源项目 a19c7933-4eda-4176-aebd-30fe7e1ad292,`extracted/The Rust Programming Language(第2版)/_epub-src/c02.xhtml`,块 0097) - 结论依据:原文解释首次解析选定版本,后续构建复用锁文件。 - 原始内容:When you build a project for the first time, Cargo figures out all the versions of the dependencies that fit the criteria and then writes them to the Cargo.lock file. When you build your project in the future, Cargo will see that the Cargo.lock file exists and will use the versions specified there rather than doing all the work of figuring out versions again.