知识卡片

普通读书笔记卡 · 6076.b.1

功能合并要求保持可叠加

理解等级:中级

同一合并范围内,多个依赖路径请求的feature取并集,一条路径关闭默认并不能否决另一条路径启用。功能应尽量只增加能力,避免互斥。合并也受resolver影响:版本2会分离部分构建依赖、开发依赖及非当前目标配置,不能把并集说成无条件覆盖整图。

范围依据:Cargo feature resolver说明,2026-10-27查阅。

这张卡片看不懂?

已有反馈 · 0 / 10 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • Chapter 4. Dependencies Features · 查看原书依据

      feature unification. This means that a crate will get built with the union of all of the features that are requested by anything in the build graph. In other words, if some other dependency in the build graph also relies on somecrate, but with just featureB enabled, then the crate will be built with all of featureA, featureB, and rand enabled, to satisfy eve

    参考来源

    - 位置:《Effective Rust 35 Specific Ways to Improve Your Rust Code (David Drysdale)》第4章《Features》(spine8;extracted/Effective Rust 35 Specific Ways to Improve Your Rust Code (David Drysdale)/_epub-src/OEBPS/ch04.html;u131-ch04-023)。 - 结论依据:原文在“feature unification”附近的定义、例子或代码支撑本卡核心说明:同一合并范围内,多个依赖路径请求的feature取并集,一条路径关闭默认并不能否决另一条路径启用。边界按已读前提解释;示例未执行。 - 原始内容:feature unification. This means that a crate will get built with the union of all of the features that are requested by anything in the build graph. In other words, if some other dependency in the build graph also relies on somecrate, but with just featureB enabled, then the crate will be built with all of featureA, featureB, and rand enabled, to satisfy eve