1

ハイパー クレートからimpl_headerマクロを使用してカスタム 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 `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`.

なぜこれが起こるのか、どうすれば修正できますか?

ありがとうございました

4

1 に答える 1

3

これはハイパーの問題であり、バグを報告する必要があるというレナートの意見に同意します (または、プル リクエストを送信することをお勧めします)。ただし、今のところ回避したい場合はheader、独自のものとして再エクスポートできます。

#[macro_use]
extern crate hyper;

pub use hyper::header as header;

struct CustomHeader;
impl_header!(CustomHeader, "value", String);

fn main() {}

残念ながら、これはまったく新しいエラーの波のロックを解除するだけです。

于 2015-02-15T16:38:23.367 に答える