Merge pull request #503 from pyfisch/nice2

refactor(headers): Improve docs, fix nits, make formatting faster
This commit is contained in:
Sean McArthur
2015-05-04 11:11:08 -07:00
26 changed files with 279 additions and 131 deletions

View File

@@ -124,8 +124,16 @@ macro_rules! test_header {
let value = HeaderField::parse_header(&a[..]);
let result = format!("{}", value.unwrap());
let expected = String::from_utf8(raw[0].to_vec()).unwrap();
let result_cmp: Vec<String> = result.to_ascii_lowercase().split(' ').map(|x| x.to_string()).collect();
let expected_cmp: Vec<String> = expected.to_ascii_lowercase().split(' ').map(|x| x.to_string()).collect();
let result_cmp: Vec<String> = result
.to_ascii_lowercase()
.split(' ')
.map(|x| x.to_string())
.collect();
let expected_cmp: Vec<String> = expected
.to_ascii_lowercase()
.split(' ')
.map(|x| x.to_string())
.collect();
assert_eq!(result_cmp.concat(), expected_cmp.concat());
}
};
@@ -258,8 +266,9 @@ macro_rules! header {
impl $crate::header::HeaderFormat for $id {
fn fmt_header(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
match *self {
$id::Any => write!(f, "*"),
$id::Items(ref fields) => $crate::header::parsing::fmt_comma_delimited(f, &fields[..])
$id::Any => f.write_str("*"),
$id::Items(ref fields) => $crate::header::parsing::fmt_comma_delimited(
f, &fields[..])
}
}
}