rust - cargo 中的自定义 cfg 目标?

标签 rust rust-cargo

rustc --cfg foo

我如何在 cargo 中执行此操作?这就是 features 的用途吗?

功能似乎只适用于可选依赖项。

最佳答案

是的。 http://doc.crates.io/manifest.html#rules :

When a feature is selected, Cargo will call rustc with --cfg feature="${feature_name}". If a feature group is included, it and all of its individual features will be included. This can be tested in code via #[cfg(feature = "foo")]

关于rust - cargo 中的自定义 cfg 目标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28064409/

相关文章:

types - 使用rust ;类型的命名空间中包含哪些类型?

rust - 用于 lib 的 Cargo.toml

facebook - 错误 无法执行事务 : Transaction failed with vm status: Validation(UnknownScript)

rust - 调用cargo-binutils命令时,是否可以使用xbuild代替build?

import - 如何在另一个 bin 中重用主 bin 中的代码?

rust - 在闭包内使用 Vector,无需克隆

rust - 有没有办法绕过原子操作的成本?

rust - 如何使用FFI将2D矢量从Rust传递到Fortran?

rust - 为什么反引用强制不适用于嵌套的Vec?

rust - "unresolved import -- maybe a missing extern"extern声明存在时