我正在尝试使用此源作为教程使用 Iron 构建 Web 服务,但在编译 hyper 时出现错误:
Compiling hyper v0.9.17
/root/.cargo/registry/src/github.com-88ac128001ac3a9a/hyper-0.9.17/src/header/common/accept_language.rs:62:23: 62:30 error: macro undefined: 'langtag!'
/root/.cargo/registry/src/github.com-88ac128001ac3a9a/hyper-0.9.17/src/header/common/accept_language.rs:62 qitem(langtag!(en;;;US)),
^~~~~~~
/root/.cargo/registry/src/github.com-88ac128001ac3a9a/hyper-0.9.17/src/header/common/accept_language.rs:63:34: 63:41 error: macro undefined: 'langtag!'
/root/.cargo/registry/src/github.com-88ac128001ac3a9a/hyper-0.9.17/src/header/common/accept_language.rs:63 QualityItem::new(langtag!(en), Quality(500)),
^~~~~~~
/root/.cargo/registry/src/github.com-88ac128001ac3a9a/hyper-0.9.17/src/header/common/accept_language.rs:64:23: 64:30 error: macro undefined: 'langtag!'
/root/.cargo/registry/src/github.com-88ac128001ac3a9a/hyper-0.9.17/src/header/common/accept_language.rs:64 qitem(langtag!(fr)),
^~~~~~~
我正在使用的版本:
- 货物 0.8.0(建于 2016-03-22)
- 锈病 1.7.0
货运.toml
[package]
name = "hello"
version = "0.1.0"
authors = ["root"]
[dependencies]
language-tags = "0.2.2"
iron = "0.4.0"
main.rs:
extern crate iron;
use iron::prelude::*;
use iron::status;
use iron::mime::Mime;
fn main() {
Iron::new(|_: &mut Request| {
let content_type = "application/json".parse::<Mime>().unwrap();
Ok(Response::with((content_type, status::Ok, "{ respone: \"Hello world!\" }")))
}).http("localhost:3009").unwrap();
}
我只在 Cargo.toml 中添加了语言标签,因为我认为它可以解决我的问题。没有进行其他更改。