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
27
28
29
use crate::*;

impl<T: Obj> Set<T> {
    /// Constructs an empty Set.
    pub fn new() -> Self {
        Self(Default::default())
    }

    /// Checks whether `t` is contained in `self`.
    pub fn contains(&self, t: T) -> bool {
        self.0.call_ref_unchecked(|s| {
            s.contains(&t)
        })
    }

    /// Inserts `t` into `self`.
    pub fn insert(&mut self, t: T) {
        self.0.mutate(|s| {
            s.insert(t);
        });
    }

    /// Removes `t` from `self`.
    pub fn remove(&mut self, t: T) {
        self.0.mutate(|s| {
            s.remove(&t);
        });
    }
}