Manishearth/triomphe

Support ThinArc for other dynamically sized types

thomcc opened this issue · 5 comments

A ThinArcStr would be pretty easy to support (would just wrap a ThinArc<H, u8> -- you can already do this by using triomphe).

The use case I care more about would be a way of having a 1-pointer Arc (pretty useful for FFI stuff)... but I'm not sure how possible this is though, given that we don't have a way to get a trait object vtable pointer...

Even if we can obtain that, the layout of that vtable can still change though.

So maybe just generate an explicit vtable for the types you care?

It probably can be done with the new (unstable) pointer metadata APIs

But ASAIK it doesn't provide any API for retrieving the vtable and call one of these methods.

you can reconstruct the trait object as an &dyn on the rust side

Sorry I misunderstood the topic.
I was thinking about calling rust dyn trait from C/C++.

If you are talking about passing the pointer to C/C++ then get it back, I think to_raw_parts and from_raw_parts can be used to archive this, though this are available only on nightly channel.