Another project
0

Configure Feed

Select the types of activity you want to include in your feed.

at main 454 B View raw
1use std::collections::BTreeSet; 2 3#[must_use] 4pub fn dedup_preserving_order<T, I>(items: I) -> Vec<T> 5where 6 T: Copy + Ord, 7 I: IntoIterator<Item = T>, 8{ 9 items 10 .into_iter() 11 .fold( 12 (Vec::new(), BTreeSet::<T>::new()), 13 |(mut acc, mut seen), item| { 14 if seen.insert(item) { 15 acc.push(item); 16 } 17 (acc, seen) 18 }, 19 ) 20 .0 21}