Closed jrmuizel closed 4 years ago
Yep that's an oversight! Should be easy enough to fix
Okay thought about this a bit more. An impl could exist here, but I don't know if it'd do what you want. The obvious solution looks like this:
unsafe impl<T: Scan + Copy> Scan for Cell<T> {
#[inline]
fn scan(&self, scanner: &mut Scanner<'_>) {
self.get().scan(scanner);
}
}
But notice the Copy
bound. Gc
is not copy, and scan
is only supposed to note Gc
s that you own. So effectively this is equivalent to an empty scan:
unsafe impl<T: Scan + Copy> Scan for Cell<T> {
#[inline]
fn scan(&self, scanner: &mut Scanner<'_>) { }
}
The other option would be to delve into unsafe code and write an impl based on cell.as_ptr
, which could be made safe by placing additional constraints on the implementation of scan
.
Do you have a usecase for this, and if so, do you need an impl for non-copy types?
(@jrmuizel meant to tag you in the above)
An implementation with a Copy
bound is fine. The use case is something like:
#[derive(Scan)]
struct A {
next: Gc<B>,
count: Cell<i32>,
}
This currently fails.
Published a release to crates.io, if you update to v0.1.2 you'll pick up this change
I think it should be able to.