Skip to content

Commit 0680201

Browse files
committed
Implement GcErase + GcRebrand for indexmap
1 parent 4b40df2 commit 0680201

File tree

1 file changed

+27
-11
lines changed

1 file changed

+27
-11
lines changed

src/manually_traced/indexmap.rs

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,25 @@ unsafe impl<K, V> GcSafe for IndexMap<K, V> where
3636
K: GcSafe + TraceImmutable + Eq + Hash, V: GcSafe {
3737
const NEEDS_DROP: bool = true; // IndexMap has internal memory
3838
}
39-
unsafe impl<'new_gc, Id, K, V> GcBrand<'new_gc, Id> for IndexMap<K, V>
40-
where Id: CollectorId, K: TraceImmutable + Eq + Hash + GcBrand<'new_gc, Id>,
41-
V: GcBrand<'new_gc, Id>,
42-
<K as GcBrand<'new_gc, Id>>::Branded: TraceImmutable + Eq + Hash + Sized,
43-
<V as GcBrand<'new_gc, Id>>::Branded: Sized {
39+
unsafe impl<'new_gc, Id, K, V> GcRebrand<'new_gc, Id> for IndexMap<K, V>
40+
where Id: CollectorId, K: TraceImmutable + Eq + Hash + GcRebrand<'new_gc, Id>,
41+
V: GcRebrand<'new_gc, Id>,
42+
<K as GcRebrand<'new_gc, Id>>::Branded: TraceImmutable + Eq + Hash + Sized,
43+
<V as GcRebrand<'new_gc, Id>>::Branded: Sized {
4444
type Branded = IndexMap<
45-
<K as GcBrand<'new_gc, Id>>::Branded,
46-
<V as GcBrand<'new_gc, Id>>::Branded
45+
<K as GcRebrand<'new_gc, Id>>::Branded,
46+
<V as GcRebrand<'new_gc, Id>>::Branded
47+
>;
48+
}
49+
50+
unsafe impl<'a, Id, K, V> GcErase<'a, Id> for IndexMap<K, V>
51+
where Id: CollectorId, K: TraceImmutable + Eq + Hash + GcErase<'a, Id>,
52+
V: GcErase<'a, Id>,
53+
<K as GcErase<'a, Id>>::Erased: TraceImmutable + Eq + Hash + Sized,
54+
<V as GcErase<'a, Id>>::Erased: Sized {
55+
type Erased = IndexMap<
56+
<K as GcErase<'a, Id>>::Erased,
57+
<V as GcErase<'a, Id>>::Erased
4758
>;
4859
}
4960

@@ -70,8 +81,13 @@ unsafe impl<V> Trace for IndexSet<V>
7081
Ok(())
7182
}
7283
}
73-
unsafe impl<'new_gc, Id, V> GcBrand<'new_gc, Id> for IndexSet<V>
74-
where Id: CollectorId, V: GcBrand<'new_gc, Id> + TraceImmutable + Eq + Hash,
75-
<V as GcBrand<'new_gc, Id>>::Branded: TraceImmutable + Eq + Hash, {
76-
type Branded = IndexSet<<V as GcBrand<'new_gc, Id>>::Branded>;
84+
unsafe impl<'new_gc, Id, V> GcRebrand<'new_gc, Id> for IndexSet<V>
85+
where Id: CollectorId, V: GcRebrand<'new_gc, Id> + TraceImmutable + Eq + Hash,
86+
<V as GcRebrand<'new_gc, Id>>::Branded: TraceImmutable + Eq + Hash, {
87+
type Branded = IndexSet<<V as GcRebrand<'new_gc, Id>>::Branded>;
88+
}
89+
unsafe impl<'a, Id, V> GcErase<'a, Id> for IndexSet<V>
90+
where Id: CollectorId, V: GcErase<'a, Id> + TraceImmutable + Eq + Hash,
91+
<V as GcErase<'a, Id>>::Erased: TraceImmutable + Eq + Hash, {
92+
type Erased = IndexSet<<V as GcErase<'a, Id>>::Erased>;
7793
}

0 commit comments

Comments
 (0)