是否可以禁用 Cargo 中的单个默认功能?

Is it possible to disable a single default feature in Cargo?

根据阅读 this page,它指出您需要关闭所有默认设置以覆盖它们。

With the exception of the default feature, all features are opt-in. To opt out of the default feature, use default-features = false and cherry-pick individual features.

我使用过的其他构建系统(CMake、SCons、Autotools、Jam)都允许更改单个默认值。

Cargo 可以吗?


这很有用,因为在大多数情况下我想使用默认选项,只需要稍作调整。 对我来说同样重要的是,在未来 - 开发人员认为应该默认启用的新功能不会在我的构建中被禁用,因为我选择调整一个不相关的功能。

编辑:opened issue regarding this feature.

这目前不可能,但您的动机听起来很合理。可以将改进 Cargo 的想法提交为 GitHub issues or (for more major things than this) RFCs

目前,不可以。您必须禁用所有 "default" 功能,然后选择重新启用您想要的功能。所以你必须知道 "default" 列表是什么,opt-back-in 除了你想忽略的那个。

GH issue 描述了状态并讨论了可能性,但仍然开放(3 年后)。