知识卡片
功能启用可关联默认与依赖
Cargo feature可启用其他feature或可选依赖,default定义默认集合;–no-default-features或依赖中的default-features=false可停止本路径主动启用默认集合。optional依赖通常产生同名feature,使用dep:引用可取消这个隐式公开名。配置名称需精确匹配,不会自动互换连字符与下划线。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- Chapter 4. Dependencies Features · 查看原书依据
optional = true } hex = "^0.4" Given that there are only five entries in the [features] stanza; there are clearly a couple of subtleties to watch out for. The first is that the default line in the [features] stanza is a special feature name, used to indicate to cargo which of the features should be enabled by default. These features can still be disabled by
参考来源
- 位置:《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-022)。
- 结论依据:原文在“optional = true”附近的定义、例子或代码支撑本卡核心说明:Cargo feature可启用其他feature或可选依赖,default定义默认集合;--no-default-features或依赖中的default-features=false可停止本路径主动启用默认集合。边界按已读前提解释;示例未执行。
- 原始内容:optional = true } hex = "^0.4" Given that there are only five entries in the [features] stanza; there are clearly a couple of subtleties to watch out for. The first is that the default line in the [features] stanza is a special feature name, used to indicate to cargo which of the features should be enabled by default. These features can still be disabled by