知识卡片
先弃用再移除降低迁移成本
需发布不兼容接口时,可先在兼容版本提供新入口,标记旧入口弃用并说明迁移,再于主版本移除。若行为已不兼容,也应通过类型或接口变化使旧用法明显失败,避免同一签名静默接受不同语义。过渡期降低迁移难度,却仍需同步维护与验证。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- Chapter 4. Dependencies Semver for Crate Authors · 查看原书依据
marks the older variant as deprecated, including an indication of how to migrate. Release a major version update that removes the deprecated parts of the API. A more subtle point is make breaking changes breaking. If your crate is changing its behavior in a way that’s actually incompatible for existing users but that could reuse the same API: don’t. Force a
参考来源
- 位置:《Effective Rust 35 Specific Ways to Improve Your Rust Code (David Drysdale)》第4章《Semver for Crate Authors》(spine8;extracted/Effective Rust 35 Specific Ways to Improve Your Rust Code (David Drysdale)/_epub-src/OEBPS/ch04.html;u116-ch04-005)。
- 结论依据:原文在“marks the older variant as deprecated”附近的定义、例子或代码支撑本卡核心说明:需发布不兼容接口时,可先在兼容版本提供新入口,标记旧入口弃用并说明迁移,再于主版本移除。边界按已读前提解释;示例未执行。
- 原始内容:marks the older variant as deprecated, including an indication of how to migrate. Release a major version update that removes the deprecated parts of the API. A more subtle point is make breaking changes breaking. If your crate is changing its behavior in a way that’s actually incompatible for existing users but that could reuse the same API: don’t. Force a