diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2020-01-06 18:03:32 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2020-01-06 18:07:55 +0100 |
commit | cceb01a9eb7eb15903dc29fc8ef65dcec755d1d2 (patch) | |
tree | 94d115407a9d83294150216ddda905703332a901 | |
parent | c4eb20bc4b73e9a886ab200b49ab370a775c87cd (diff) |
fixup! Add function to get all header keys from Email object
-rw-r--r-- | src/lib.rs | 16 |
1 files changed, 14 insertions, 2 deletions
@@ -274,8 +274,20 @@ impl Email { self.fields.get(&name.to_lowercase()).map(|v| v[0].as_str()) } - pub fn header_keys(&self) -> Vec<&String> { - self.fields.keys().collect() + /// Returns all names of header fields found in the Email + /// + /// # Example + /// + /// ```no_run + /// # use mda::Email; + /// let email = Email::from_stdin()?; + /// for name in email.header_field_names() { + /// println!("{}: {:?}", name, email.header_field(name)); + /// } + /// # Ok::<(), Box<dyn std::error::Error>>(()) + /// ``` + pub fn header_field_names(&self) -> Vec<&str> { + self.fields.keys().map(::std::ops::Deref::deref).collect() } /// Returns the values from all occurrences of a header field, if present. |