~soywod/pimalaya

email-lib: replace &Vecs with slices v1 APPLIED

Perma Alesheikh: 1
 replace &Vecs with slices

 1 files changed, 6 insertions(+), 6 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~soywod/pimalaya/patches/49291/mbox | git am -3
Learn more about email & git

[PATCH email-lib] replace &Vecs with slices Export this patch

Since &Vec involves a new object and &[T] is does the trick, it should
usually be prefered.

Signed-off-by: Perma Alesheikh <me@prma.dev>
---
 mml/src/message/header.rs | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/mml/src/message/header.rs b/mml/src/message/header.rs
index 99f40d6..ee06d89 100644
--- a/mml/src/message/header.rs
+++ b/mml/src/message/header.rs
@@ -165,11 +165,11 @@ fn extract_email_from_addr(a: &Addr) -> Option<String> {
    a.address.as_ref().map(|a| a.to_string())
}

fn extract_first_email_from_addrs(a: &Vec<Addr>) -> Option<String> {
fn extract_first_email_from_addrs(a: &[Addr]) -> Option<String> {
    a.iter().next().and_then(extract_email_from_addr)
}

fn extract_emails_from_addrs(a: &Vec<Addr>) -> Vec<String> {
fn extract_emails_from_addrs(a: &[Addr]) -> Vec<String> {
    a.iter().filter_map(extract_email_from_addr).collect()
}

@@ -181,16 +181,16 @@ fn extract_emails_from_group(g: &Group) -> Vec<String> {
    extract_emails_from_addrs(&g.addresses)
}

fn extract_first_email_from_groups(g: &Vec<Group>) -> Option<String> {
fn extract_first_email_from_groups(g: &[Group]) -> Option<String> {
    g.first()
        .map(|g| &g.addresses)
        .and_then(extract_first_email_from_addrs)
        .and_then(|i| extract_first_email_from_addrs(i))
}

fn extract_emails_from_groups(g: &Vec<Group>) -> Vec<String> {
fn extract_emails_from_groups(g: &[Group]) -> Vec<String> {
    g.iter()
        .map(|g| &g.addresses)
        .flat_map(extract_emails_from_addrs)
        .flat_map(|i| extract_emails_from_addrs(i))
        .collect()
}

-- 
2.43.0