Skip to content

Commit d38fe19

Browse files
committed
Don't require T: TraceImmutable for IndexMap
We can't do this on the regular HashMap, because we don't have mutable access to the keys...
1 parent 91a189f commit d38fe19

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/manually_traced/indexmap.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ use zerogc_derive::unsafe_gc_impl;
66

77
unsafe_gc_impl! {
88
target => IndexMap<K, V, S>,
9-
params => [K: TraceImmutable, V, S: 'static],
9+
params => [K, V, S: 'static],
1010
bounds => {
11-
Trace => { where K: TraceImmutable, V: Trace, S: 'static },
11+
Trace => { where K: Trace, V: Trace, S: 'static },
1212
TraceImmutable => { where K: TraceImmutable, V: TraceImmutable, S: 'static },
1313
TrustedDrop => { where K: TrustedDrop, V: TrustedDrop, S: 'static },
1414
GcSafe => { where K: GcSafe<'gc, Id>, V: GcSafe<'gc, Id>, S: 'static },
@@ -17,10 +17,19 @@ unsafe_gc_impl! {
1717
NEEDS_TRACE => K::NEEDS_TRACE || V::NEEDS_TRACE,
1818
NEEDS_DROP => true, // Internal memory
1919
collector_id => *,
20-
visit => |self, visitor| {
21-
for (key, value) in self.#iter() {
20+
trace_mut => |self, visitor| {
21+
for idx in 0..self.len() {
22+
let (key, value) = self.get_index_mut(idx).unwrap();
23+
visitor.visit::<K>(key)?;
24+
visitor.visit::<V>(value)?;
25+
}
26+
// NOTE: S: 'static implies S: NullTrace
27+
Ok(())
28+
},
29+
trace_immutable => |self, visitor| {
30+
for (key, value) in self.iter() {
2231
visitor.visit_immutable::<K>(key)?;
23-
visitor.#visit_func::<V>(value)?;
32+
visitor.visit_immutable::<V>(value)?;
2433
}
2534
// NOTE: S: 'static implies S: NullTrace
2635
Ok(())

0 commit comments

Comments
 (0)