什么是#[警告(不稳定)]关于Rust? [英] What is #[warn(unstable)] about in Rust?

查看:290
本文介绍了什么是#[警告(不稳定)]关于Rust?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用Rust 1.0 alpha编写的非常简单的cat函数。

I have a really simple cat function written in the Rust 1.0 alpha.

use std::io;

fn main(){
    let mut reader = io::stdin();
    loop {
        let input = reader.read_line().ok().expect("Failed to read line");
        print!("{}", input);
    }
}

当我编译它时,我收到以下警告:

When I compile it, I get the following warnings:

bindings.rs:5:26: 5:35 warning: use of unstable item, #[warn(unstable)] on by default
bindings.rs:5         let mut reader = io::stdin();
                                       ^~~~~~~~~
bindings.rs:6:28: 6:39 warning: use of unstable item, #[warn(unstable)] on by default
bindings.rs:6         let input = reader.read_line().ok().expect("Failed to read line");
                                         ^~~~~~~~~~~

有没有办法补救这些警告?

Is there a way to remedy these warnings?

推荐答案

对于1.0版本,Rust希望提供关于语言和标准库的哪些功能可用的非常有力的保证对于语言的整个生命。这不是一件容易的事!

For the 1.0 release, Rust wants to provide a very strong guarantee about what features of the language and standard library will be available for the entire life of the language. This is not an easy feat!

新的,未经测试的或刚刚未完全烹饪的功能将标有稳定属性,而你将无法在测试版或发布版中使用不稳定的功能。您只能在夜间构建中使用它们。

New, untested, or just not-fully-cooked features will be marked with a stability attribute, and you won't be able to use unstable features in the beta or release. You will only be able to use them in the nightly builds.

然而,在 alpha 期间,它们只是警告。如果您需要使用alpha中的某个功能并将其标记为 unstable ,那么您需要确保它在测试版之前变得稳定(或者您找到了替代解决方案) !

During the alpha however, they are simply warnings. If you need to use a feature in the alpha and it's marked as unstable, then you will want to make sure it becomes stable (or you find an alternate solution) before the beta!

在这种情况下,整个IO子系统正在进行最后一分钟的更改,因此它被标记为不稳定。

In this case, the entire IO subsystem is undergoing last-minute changes, so it's marked as unstable.

编辑1

PR 21543 登陆,当前世界称为 std :: io 将被重命名为 std :: old_io 。新编写的代码将进入 std :: io ,旧版本将被弃用。

When PR 21543 lands, the current world known as std::io will be renamed as std::old_io. Newly-written code will go into std::io and the old version will be deprecated.

这篇关于什么是#[警告(不稳定)]关于Rust?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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