【问题标题】:"use of unstable library feature 'collections'" using nightly“使用不稳定的库功能'集合'”使用 nightly
【发布时间】:2020-12-20 09:41:11
【问题描述】:

这个

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,每晚启用不稳定功能。我也试过stable和beta,但错误是完全一样的。那么这里有什么问题呢?

【问题讨论】:

    标签: rust


    【解决方案1】:

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

    另请参阅related SO question

    【讨论】:

      【解决方案2】:

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

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

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

      【讨论】:

        猜你喜欢
        • 2022-12-06
        • 1970-01-01
        • 2023-01-23
        • 2021-01-08
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多