~ireas/public-inbox

merge-rs: Hashmap feature proposal v1 PROPOSED

Added function to recursively take elements in a hashmap only if the key
is present in `left` and `right`.

Gabouchet (1):
  feat(hashmap): Intersection

 src/lib.rs | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

-- 
2.34.5
#930882 archlinux-msrv.yml failed
#930883 archlinux.yml failed
merge-rs/patches: FAILED in 3m4s

[Hashmap feature proposal][0] from [~gabouchet][1]

[0]: https://lists.sr.ht/~ireas/public-inbox/patches/38541
[1]: mailto:gabriel.hamel.pro@gmail.com

✗ #930882 FAILED merge-rs/patches/archlinux-msrv.yml https://builds.sr.ht/~ireas/job/930882
✗ #930883 FAILED merge-rs/patches/archlinux.yml      https://builds.sr.ht/~ireas/job/930883
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/~ireas/public-inbox/patches/38541/mbox | git am -3
Learn more about email & git

[PATCH merge-rs 1/1] feat(hashmap): Intersection Export this patch

From: Gabouchet <gabriel.hamel.pro@gmail.com>

---
 src/lib.rs | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/src/lib.rs b/src/lib.rs
index ab9b4ab..e289d84 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -298,4 +298,19 @@ pub mod hashmap {
            }
        }
    }

    /// Merge recursively elements if the key is present in `left` and `right`.
    pub fn intersection<K: Eq + Hash, V: crate::Merge>(
        left: &mut HashMap<K, V>,
        right: HashMap<K, V>,
    ) {
        use std::collections::hash_map::Entry;

        for (k, v) in right {
            match left.entry(k) {
                Entry::Occupied(mut existing) => existing.get_mut().merge(v),
                _ => {}
            }
        }
    }
}
-- 
2.34.5
merge-rs/patches: FAILED in 3m4s

[Hashmap feature proposal][0] from [~gabouchet][1]

[0]: https://lists.sr.ht/~ireas/public-inbox/patches/38541
[1]: mailto:gabriel.hamel.pro@gmail.com

✗ #930882 FAILED merge-rs/patches/archlinux-msrv.yml https://builds.sr.ht/~ireas/job/930882
✗ #930883 FAILED merge-rs/patches/archlinux.yml      https://builds.sr.ht/~ireas/job/930883