如何将'功能标记'传递给Cargo中的子依赖项?

bur*_*geo 11 rust rust-cargo

我在Cargo写一个图书馆.如果这个库依赖于另一个库libc,它暴露了一个特性(在这种情况下use_std),我如何创建一个我公开的功能在我的依赖项中启用或禁用该功能?

查看货物文档,看起来没有指定的官方方式来执行此操作.

She*_*ter 14

您链接到的文档:

# Features can be used to reexport features of other packages. The `session`
# feature of package `awesome` will ensure that the `session` feature of the
# package `cookie` is also enabled.
session = ["cookie/session"]
Run Code Online (Sandbox Code Playgroud)

那够了吗?

  • 嗯,如果我有一个像 [`ascii`](https://github.com/tomprogrammer/rust-ascii) 这样的依赖项,它公开了一个 `no_std` 标志,如果我的 `use_std` 标志是,我想_禁用_启用? (2认同)