Skip to content

Instantly share code, notes, and snippets.

@steveatinfincia
Created January 12, 2017 03:51
Show Gist options
  • Save steveatinfincia/ec682b6443633d9287cdd3afec058922 to your computer and use it in GitHub Desktop.
Save steveatinfincia/ec682b6443633d9287cdd3afec058922 to your computer and use it in GitHub Desktop.
// error:
error[E0277]: the trait bound `mymodule::MyHeader: mymodule::reqwest::header::Header` is not satisfied
// in crate root
#[macro_use] extern crate hyper;
// original code in mymodule using header! macro from Hyper
extern crate reqwest;
extern crate serde;
extern crate serde_json;
extern crate hyper;
header! { (MyHeader, "My-Header") => [String] }
// expands to (among other things):
pub struct MyHeader(pub String);
impl ::header::Header for MyHeader {
fn header_name() -> &'static str {
"My-Header"
}
fn parse_header(raw: &[Vec<u8>]) -> ::Result<Self> {
::header::parsing::from_one_raw_str(raw).map(MyHeader)
}
}
impl ::header::HeaderFormat for MyHeader {
fn fmt_header(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
::std::fmt::Display::fmt(&**self, f)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment