知识卡片
版本号承诺宏兼容性
稳定 crate 通过语义化版本告诉调用方升级的兼容范围。兼容的 bug 修复提高补丁版本,向后兼容的新功能提高次版本,破坏已有调用的变化提高主版本。例如从 1.1.0 修补到 1.1.1,增加兼容功能到 1.2.0,而改变已有接口则进入 2.0.0。
宏的接口还体现在接受的语法和展开后调用方所使用的类型与方法。Cargo 的兼容范围可能使项目自动采用同一主版本中的后续版本,因此无标识的破坏性变更会让原来可编译的调用突然失败。
相关卡片 [[生成代码使用完整路径]]、[[发布检查面向实际包]]。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- Macros and the outside world 发布前检查与版本承诺 · 查看原书依据
This means that bug fixes increase the patch version (e.g., 1.1.0 => 1.1.1), functionality that is backward compatible increases the minor (e.g., 1.1.0 => 1.2.0), and backward-incompatible changes increase the major version (e.g., 1.0.0 => 2.0.0). This is especially important in Rust because Cargo allows you to specify dependencies solely by major: trybuild = "1", for example. Introducing a breaking change without bumping the major version might cause projects to suddenly and unexpectedly break.