libspecr/set/
mod.rs

1use std::collections::HashSet;
2
3use im::HashSet as IMHashSet;
4
5use crate::*;
6
7mod func;
8mod iter;
9
10#[derive(Clone, Copy, Hash, PartialEq, Eq, Debug, GcCompat)]
11/// Garbage-collected hash set implementing `Copy`.
12pub struct Set<T: Obj>(pub(crate) GcCow<IMHashSet<T>>);
13
14impl<T: Obj> GcCompat for IMHashSet<T> {
15    fn points_to(&self, m: &mut HashSet<usize>) {
16        for x in self.iter() {
17            x.points_to(m);
18        }
19    }
20}
21
22// This is not #[derive]d, as this would wrongly require T: Default.
23impl<T: Obj> Default for Set<T> {
24    fn default() -> Self {
25        Self(Default::default())
26    }
27}