diff options
author | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-09-20 10:48:27 +0300 |
---|---|---|
committer | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-09-20 21:35:45 +0300 |
commit | f066f35410cd631955cff4c5ae1ec49f9826bb36 (patch) | |
tree | d012361a6a88fe42dc1ecdab4bc42eb7304d9f51 | |
parent | bee1502499ac28a0b14cdac7fbf2a565b1698db4 (diff) |
melib: add get_tags to support subaddressing
-rw-r--r-- | melib/src/email/address.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/melib/src/email/address.rs b/melib/src/email/address.rs index 789eec4e..dd771d92 100644 --- a/melib/src/email/address.rs +++ b/melib/src/email/address.rs @@ -65,6 +65,16 @@ impl Address { Address::Group(_) => None, } } + + pub fn get_tags(&self, separator: char) -> Vec<String> { + let mut ret = Vec::new(); + if let email = self.get_email() { + let at_pos = email.as_bytes().iter().position(|&b| b == b'@').unwrap(); + let email: &str = email[..at_pos].into(); + ret.extend(email.split(separator).skip(1).map(str::to_string)); + } + ret + } } impl Eq for Address {} |