"使用不稳定的库特征'集合'"每晚使用

Cab*_*ero 20 rust

这个

fn main() {

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

}
Run Code Online (Sandbox Code Playgroud)

产生错误

error: use of unstable library feature 'collections'
       test.to_lowercase();
            ^~~~~~~~~~~~~~
Run Code Online (Sandbox Code Playgroud)

但我正在使用

rustc 1.2.0-nightly (f76d9bcfc 2015-05-28) (built 2015-05-28)
Run Code Online (Sandbox Code Playgroud)

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

DK.*_*DK. 27

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

另见这个相关的SO问题.


oli*_*obk 14

如果您查看错误消息(每晚),则会提示您需要做什么来激活此功能(仅因为它在夜间,并不意味着该功能处于活动状态)

<anon>:3:10: 3:24 help: add #![feature(collections)] to the crate attributes to enable
error: aborting due to previous error
Run Code Online (Sandbox Code Playgroud)

始终阅读完整的错误消息,尤其是note:和help:部分.这些通常会告诉您如何修复错误.