cxx
cxx copied to clipboard
Unclear how to get mutable reference out of a SharedPtr
From what I understand, to be able to call non const member functions, we need to have a mutable reference to a pinned object. Like:
fn getRouteIdsExt(feed: Pin<&mut Feed>) -> UniquePtr<CxxVector<i32>>;
However the Feed class in the c++ codebase inherits from std::enable_shared_from_this. This means I can only get SharedPtr's of it (instead of a UniquePtr), and I can't think of a way to get a mutable reference out of a SharedPtr.
In pure rust, to get interior mutability out of an Arc (which is the equivalent of shared_ptr), I can use a Mutex inside it, but I'm not sure what I can do here?
Is there any way to get mutability from a SharedPtr?
See discussion in #537