Rust 调用外部机箱中定义的宏时未解析的导入
我试图使用hyper-crate中的宏实现自定义HTTP头,但它似乎无法解析Rust 调用外部机箱中定义的宏时未解析的导入,rust,hyper,Rust,Hyper,我试图使用hyper-crate中的宏实现自定义HTTP头,但它似乎无法解析hyper::header模块 这是我的密码: #[macro_use] extern crate hyper; use hyper::header; struct CustomHeader; impl_header!(CustomHeader, "value", String); 下面是编译器错误: <hyper macros>:11:14: 11:20 error: unresolved import
hyper::header
模块
这是我的密码:
#[macro_use] extern crate hyper;
use hyper::header;
struct CustomHeader;
impl_header!(CustomHeader, "value", String);
下面是编译器错误:
<hyper macros>:11:14: 11:20 error: unresolved import `header::HeaderFormat`. Maybe a missing `extern crate header`?
<hyper macros>:11 Result { use header:: HeaderFormat ; self . fmt_header ( f ) } } }
^~~~~~
<hyper macros>:1:1: 11:67 note: in expansion of impl_header!
lib.rs:4:1: 4:45 note: expansion site
error: aborting due to previous error
Could not compile `macro_issue`.
:11:14:11:20错误:未解析的导入`header::HeaderFormat`。可能是缺少了“外部板条箱标题”?
:11结果{use header::HeaderFormat;self.fmt_header(f)}}
^~~~~~
:1:1:11:67注意:在impl_标题的扩展中!
lib.rs:4:1:4:45注:扩展站点
错误:由于上一个错误而中止
无法编译“宏\u问题”。
有什么线索可以解释为什么会发生这种情况,我该如何解决
谢谢我同意Renato的观点,这是hyper的问题,你应该提交一个bug(或者更好的是一个pull请求!)。如果您现在想解决这个问题,您可以将
标题重新导出为您自己的:
#[macro_use]
extern crate hyper;
pub use hyper::header as header;
struct CustomHeader;
impl_header!(CustomHeader, "value", String);
fn main() {}
不幸的是,这只是打开了一个全新的错误浪潮,我会让你弄明白 看起来他们在引用自己的模块时没有使用。应该是一个简单的修复!