【发布时间】:2015-02-22 07:42:54
【问题描述】:
我想使用 cfg 和 Cargo 有条件地编译我的源代码,
谷歌搜索了一段时间后,
看来解决方案是使用cargo --features。
http://doc.crates.io/manifest.html
我尝试添加一些
#[cfg(feature = "foo")]
在源代码中和
cargo build --features foo
,但它说
Package `xxx v0.0.1 (file:///C:/yyy/xxx)` does not have these features: `foo`
如何让 cargo 识别特征?我必须在Cargo.toml 中添加一些内容吗?
这是我正在使用的rustc 和cargo 的版本:
C:\>rustc --version
rustc 0.13.0-nightly (42deaa5e4 2014-12-16 17:51:23 +0000)
C:\>cargo --version
cargo 0.0.1-pre-nightly (5af754d 2014-12-18 01:50:48 +0000)
【问题讨论】:
标签: rust rust-cargo