【发布时间】:2017-02-22 14:38:58
【问题描述】:
我正在用 Cargo 编写一个库。如果这个库依赖于另一个库,如 libc,它公开了一个特性(在本例中为 use_std),我如何使我公开的特性在我的依赖项中启用或禁用该特性?
查看cargo documentation,似乎没有指定官方方法来执行此操作。
【问题讨论】:
标签: rust rust-cargo
我正在用 Cargo 编写一个库。如果这个库依赖于另一个库,如 libc,它公开了一个特性(在本例中为 use_std),我如何使我公开的特性在我的依赖项中启用或禁用该特性?
查看cargo documentation,似乎没有指定官方方法来执行此操作。
【问题讨论】:
标签: rust rust-cargo
来自the documentation you linked to:
# 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"]
够了吗?
【讨论】:
ascii 这样的依赖项,它暴露了一个 no_std 标志 - 如果我的 use_std 标志启用,我想禁用?
no_std,我觉得我听说正确的做法是拥有一个默认功能,可以使用来自std 的东西,所以也许ascii 板条箱只是倒退了.. .