如何摆脱"struct field shorthands不稳定"的错误?

spa*_*rkr 1 rust

我正在尝试使用Iron框架的Hello World应用程序.这就是我的主要内容:

extern crate iron;
extern crate router;

use iron::prelude::*;
use iron::status;
use router::Router;

fn main() {
    let mut router = Router::new();

    router.get("/", hello_world);
    router.post("/data", randomfriend);

    fn hello_world(_: &mut Request) -> IronResult<Response> {
        Ok(Response::with((status::Ok, "Hello World!")))
    }

    fn data(_: &mut Request) -> IronResult<Response> {
        Ok(Response::with((status::Ok, "Got some data")))
    }

    Iron::new(router).http("localhost:3000").unwrap();
    println!("On 3000");
}
Run Code Online (Sandbox Code Playgroud)

这是我的Cargo.toml:

[package]
name = "webserver-iron"
version = "0.1.0"

[[bin]]
name = "webapp_demo_server"

[dependencies]
iron = "*"
router = "*"
Run Code Online (Sandbox Code Playgroud)

当我运行时cargo run,我收到以下错误:

error: struct field shorthands are unstable (see issue #37340)
Run Code Online (Sandbox Code Playgroud)

似乎这个问题已得到修复,但我怎么能摆脱它呢?我有以下Rust版本:

rustc 1.16.0 (30cf806ef 2017-03-10)
Run Code Online (Sandbox Code Playgroud)

Flo*_*mer 7

结构字段缩写进入Rust 1.17.0(作为RFC 1682),因此您必须升级Rust安装.

如果您使用Rustup,请参阅这些说明如何使Rust安装保持最新.