如果在 Rust 代码中使用了“#![feature]
”声明,且在构建时出现了“#![feature]
may not be used on the stable release channel”错误提示,则需在 Cargo.toml 文件中添加以下内容:
[features]
default = ["my_crate"]
my_crate = []
[dependencies]
my_crate = { version = "x.y.z", features = ["unstable_feature"] }
其中,“my_crate”为你的 Rust 包名称,“unstable_feature”为需要使用的不稳定(未发布)特征标记名称,例如“#![feature(trait_alias)]
”。
然后在 Rust 代码中使用:
#[cfg(feature = "unstable_feature")]
来包含对不稳定特性的支持。
下一篇:budgiedebian