pub fn intersection<I, Set, T>(sets: I) -> HashSet<T>
Expand description
Takes the intersection between the given Set
iterables, with common type T
.
ยงExample
use std::collections::HashSet;
use intersection::hash_set;
let tokens = "hello,world,common";
let sets = tokens.split(',') // split to words, each word is a set.
.map(|word| word.chars()); // split word to chars, each char is an element of the set.
// we look for the common letters between the 3 words
let common_letters = hash_set::intersection(sets);
let expected = HashSet::from(['o']);
assert_eq!(common_letters, expected);