I need to implement Trace
from gc
crate in my own string type so that my other garbage-collected types can contain this string type.
Here's the full source without Trace
derived: https://github.com/matheusdiasdesouzads/rust-scalar-value-string/blob/master/src/sv_string.rs
I'm having difficulty though because one of the backend types of my string type implements Drop
to cleanup Weak
interned strings and I get conflict:
impl Drop for StringRepr0 {
fn drop(&mut self) {
if self.m_len > INTERN_LIMIT {
return;
}
let p1 = &mut *INTERNED.lock().unwrap();
let p2 = p1.get_mut(&self.m_len);
if p2.is_none() {
return;
}
let p2 = p2.unwrap();
let mut i: usize = 0;
let mut f: Vec<usize> = vec![];
for s2 in p2.iter() {
if s2.upgrade().is_none() {
f.push(i);
}
i += 1;
}
for &i in f.iter().rev() {
p2.remove(i);
}
if p2.len() == 0 {
p1.remove(&self.m_len);
}
}
}
I'm trying to derive Finalize, Trace
for StringRepr0
, but I get conflict. Any idea?