Skip to content

Instantly share code, notes, and snippets.

View CrabNejonas's full-sized avatar

Jonas Kruckenberg CrabNejonas

View GitHub Profile
@CrabNejonas
CrabNejonas / pick.rs
Last active December 14, 2023 13:11
Ports the `intersection` algorithm defined between two `BTreeSet<T>`s to a `BTreeMap<K, V>` and a `BTreeSet<K>` essentially retaining only key-value pairs who's keys are part of the set.
use std::cmp::Ordering;
use std::collections::{btree_map, btree_set, BTreeMap, BTreeSet};
use std::iter::FusedIterator;
trait IntersectionExt<K, V> {
fn pick<'a>(&'a self, other: &'a BTreeSet<K>) -> Pick<'a, K, V>
where
K: Ord;
}