我知道如何说依赖性只在windows上需要,但我(作为一名板条箱编写者)如何说功能只在windows上可用。
我试过(根据具体情况)
[target.'cfg(windows)'.features] windbg = []
但这不管用。
货物建造说
warning: unused manifest key: target.cfg(windows).features
而一个使用板条箱的客户端应用程序失败,并表示该功能不存在
目前Cargo无法指定功能的目标平台,但您可以添加 target_os 作为额外属性添加到代码中,让编译器知道您的功能只在您设置的目标上可用。
target_os
假设您已经定义了如下功能。
#[cfg(feature = "windbg")] mod windbg { //... }
您需要将其替换为:
#[cfg(all(target_os = "windows", feature = "windbg"))] mod windbg { //... }