summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJos van den Oever <jos@vandenoever.info>2018-09-12 10:03:44 +0200
committerKartikaya Gupta (kats) <staktrace@users.noreply.github.com>2018-09-12 12:35:25 -0400
commitac7ad123666b1af1dc1c243312aa4daca1535a90 (patch)
tree88f3b8c903d09d29baddb39de921f01a69c454e0
parentcf0554329324f07026b411103f84e50c1252734e (diff)
downloadmailparse-ac7ad123666b1af1dc1c243312aa4daca1535a90.tar.gz
mailparse-ac7ad123666b1af1dc1c243312aa4daca1535a90.tar.xz
Implement MailHeaderMap for [MailHeader] instead of Vec<MailHeader>
-rw-r--r--src/lib.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/lib.rs b/src/lib.rs
index ed0c5d7..51ea515 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -359,7 +359,8 @@ pub fn parse_header(raw_data: &[u8]) -> Result<(MailHeader, usize), MailParseErr
}
}
-/// A trait that is implemented by the Vec<MailHeader> returned by the parse_headers
+/// A trait that is implemented by the [MailHeader] slice. These functions are
+/// also available on Vec<MailHeader> which is returned by the parse_headers
/// function. It provides a map-like interface to look up header values by their
/// name.
pub trait MailHeaderMap {
@@ -398,7 +399,7 @@ pub trait MailHeaderMap {
fn get_all_values(&self, key: &str) -> Result<Vec<String>, MailParseError>;
}
-impl<'a> MailHeaderMap for Vec<MailHeader<'a>> {
+impl<'a> MailHeaderMap for [MailHeader<'a>] {
fn get_first_value(&self, key: &str) -> Result<Option<String>, MailParseError> {
for x in self {
if x.get_key()?.eq_ignore_ascii_case(key) {