// Calculate the union of three sets that are intersections of three original sets
let i1: BTreeSet<Item> = set1.intersection(&set2).map(|v| *v).collect();
let i2: BTreeSet<Item> = set1.intersection(&set3).map(|v| *v).collect();
let i3: BTreeSet<Item> = set2.intersection(&set3).map(|v| *v).collect();
let u: Vec<Item> = i1
.union(&i2)
.map(|v| *v)
.collect::<BTreeSet<Item>>()
.union(&i3)
.map(|v| *v)
.collect();

I am not happy that I am not able to write

let u = set1.intersection(set2).union(set1.intersection(set3)).union(set2.intersection(set3));

or more step by step,

let i1 = set1.intersection(set2);
let i2 = set1.intersection(set3);
let i3 = set2.intersection(set3);
let u = i1.union(i2).union(i3);

Any idea to write some better workable code for this simple algorithm?

let i1 = set1.intersection(&set2);
let i2 = set1.intersection(&set3);
let i3 = set2.intersection(&set3);
let u = i1.chain(i2).chain(i3).copied().collect::<BTreeSet<Item>>();