如何将功能标志“传递"到 Cargo 中的子依赖项? [英] How do I 'pass down' feature flags to subdependencies in Cargo?

查看:41
本文介绍了如何将功能标志“传递"到 Cargo 中的子依赖项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用 Cargo 编写一个库.如果这个库依赖于另一个库,比如 libc,它公开了一个特性(在在这种情况下,use_std),如何使我公开的功能在我的依赖项中启用或禁用该功能?

查看货物文档,似乎没有官方的指定的方式来做到这一点.

解决方案

来自您链接到的文档:

<块引用>

# Features 可用于重新导出其他包的功能.`会话`# 包`awesome` 的特性将确保该包的`session` 特性# 包`cookie` 也已启用.会话 = [cookie/会话"]

够了吗?

I'm writing a library in Cargo. If this library depends on another library like libc, which exposes a feature (in this case, use_std), how do I make a feature I expose enable or disable that feature in my dependency?

Looking at the cargo documentation, it looks like there's no official way specified to do this.

解决方案

From 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"]

Is that sufficient?

这篇关于如何将功能标志“传递"到 Cargo 中的子依赖项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆