perf(header): improve on MemSlice usage in headers

This commit is contained in:
Sean McArthur
2017-01-26 23:49:44 -08:00
parent 1b556389c0
commit 61364d245b
14 changed files with 190 additions and 195 deletions

View File

@@ -21,7 +21,7 @@ pub fn from_one_raw_str<T: str::FromStr>(raw: &Raw) -> ::Result<T> {
/// Reads a raw string into a value.
pub fn from_raw_str<T: str::FromStr>(raw: &[u8]) -> ::Result<T> {
let s = try!(str::from_utf8(raw));
let s = try!(str::from_utf8(raw)).trim();
T::from_str(s).or(Err(::Error::Header))
}
@@ -36,7 +36,7 @@ pub fn from_comma_delimited<T: str::FromStr>(raw: &Raw) -> ::Result<Vec<T>> {
"" => None,
y => Some(y)
})
.filter_map(|x| x.parse().ok()))
.filter_map(|x| x.trim().parse().ok()))
}
Ok(result)
}