“使用不稳定的库功能‘集合’"每晚使用 [英] "use of unstable library feature 'collections'" using nightly

查看:35
本文介绍了“使用不稳定的库功能‘集合’"每晚使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个

fn main() {

    let test = "Foo".to_string();
    test.to_lowercase();

}

产生错误

error: use of unstable library feature 'collections'
       test.to_lowercase();
            ^~~~~~~~~~~~~~

但我正在使用

rustc 1.2.0-nightly (f76d9bcfc 2015-05-28) (built 2015-05-28)

并根据 http://doc.rust-lang.org/1.0.0/book/release-channels.html 不稳定的功能每晚启用.我也试过稳定版和测试版,但错误完全一样.那么这里的问题是什么?

and according to http://doc.rust-lang.org/1.0.0/book/release-channels.html unstable features are enabled on nightly. I've also tried stable and beta, but the error is exactly the same. So what's the issue here?

推荐答案

您需要通过将 #![feature(collections)] 放在 crate 的根源文件顶部来明确选择加入.使用夜间编译器仅允许您使用不稳定的功能,它不会自动启用它们.

You need to explicitly opt-in by placing #![feature(collections)] at the top of your crate's root source file. Using a nightly compiler merely permits you to use unstable features, it doesn't automatically enable them.

另见这个相关的SO问题.

这篇关于“使用不稳定的库功能‘集合’"每晚使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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