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
30
31
32
use crate::*;
mod iter;
mod func;
#[derive(Clone, Copy, Hash, PartialEq, Eq, Debug, GcCompat)]
pub struct List<T: Obj>(pub(crate) GcCow<IMVector<T>>);
pub macro list {
() => { List::new() },
($start:expr $(,$a:expr)*) => { [$start $(,$a)* ].into_iter().collect::<List<_>>() },
($a:expr ; $b:expr) => { List::from_elem($a, Int::from($b)) },
}
impl<T: Obj> GcCompat for IMVector<T> {
fn points_to(&self, m: &mut HashSet<usize>) {
for i in self.iter() {
i.points_to(m);
}
}
fn as_any(&self) -> &dyn Any { self }
}
impl<T: Obj> Default for List<T> {
fn default() -> Self {
Self(Default::default())
}
}