1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
extern crate alloc;

use alloc::{collections::BTreeSet, vec::Vec};

pub trait Collection {
    type Item;
    fn add(self, item: Self::Item) -> Self;
}

impl<T> Collection for Vec<T> {
    type Item = T;

    fn add(mut self, item: Self::Item) -> Self {
        self.push(item);
        self
    }
}

impl<T: Ord> Collection for BTreeSet<T> {
    type Item = T;

    fn add(mut self, item: Self::Item) -> Self {
        self.insert(item);
        self
    }
}