1use std::collections::{HashMap, HashSet};
2use std::hash::Hash;
3
4pub fn xor<T: Eq + Hash + Clone>(arrays: &[&[T]]) -> Vec<T> {
5 let mut unique_counts = HashMap::new();
6
7 for array in arrays {
9 let unique_items: HashSet<_> = array.iter().cloned().collect();
10 for item in unique_items {
11 *unique_counts.entry(item).or_insert(0) += 1;
12 }
13 }
14
15 let mut result = Vec::new();
17 for array in arrays {
18 for item in *array {
19 if let Some(1) = unique_counts.get(item) {
20 if !result.contains(item) {
21 result.push(item.clone());
22 }
23 }
24 }
25 }
26
27 result
28}