Let there be a structure, J, with a lifetime 'hvec (i.e., J: 'hvec
)
Let there be an accessor structure, K, with lifetime 'visit, such that 'hvec : 'visit (i.e., the lifetime of K lasts less than the lifetime of J)
Suppose within K, there exists a mutable borrow to J.
Within K, there exists a function, M(self, [...]) that receives full ownership of self, an instance of K.
Within M(self, [...]), the idea is to execute some code, which notably includes a subroutine/closure which takes a mutable borrow of K, &mut K
. The mutable borrow of K, &mut K
, is passed in order to allow the code within the subroutine to access the mutable borrow &mut J
referred-to by &mut K
that it receives. Anyways...
The idea is to keep the owned version of K alive as the code within M(self, [...]) executes.
However, I am having a mighty fight with the borrow checker. Does anyone have an idea of how to complete this theoretical model without descending into unsafe code and transmutes?