You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
meaning that the lifetime of the returned slice is tied to the lifetime of the focus. I think the return type should actually be &'a [A],
i.e. the slice lives as long as the vector we're focusing on. This should be safe because:
The Focus doesn't own any chunk storage; it's all managed by an RrbPool.
The RrbPool won't drop a chunk so long as there exists a Vector which references it.
'a is the lifetime of the Vector which constructed the Focus.
I see that the implementation of Chunks has an unsafe hack which extends the lifetime of a slice returned from chunk_at by casting it through a raw pointer and back. It seems to me that this shouldn't be necessary and what's returned from chunk_at should already have the appropriate lifetime.
For the meantime I've put this into my code as a workaround:
vector::Focus::chunk_at
has a signature ofmeaning that the lifetime of the returned slice is tied to the lifetime of the focus. I think the return type should actually be
&'a [A]
,i.e. the slice lives as long as the vector we're focusing on. This should be safe because:
Focus
doesn't own any chunk storage; it's all managed by anRrbPool
.RrbPool
won't drop a chunk so long as there exists aVector
which references it.'a
is the lifetime of theVector
which constructed theFocus
.I see that the implementation of
Chunks
has an unsafe hack which extends the lifetime of a slice returned fromchunk_at
by casting it through a raw pointer and back. It seems to me that this shouldn't be necessary and what's returned fromchunk_at
should already have the appropriate lifetime.For the meantime I've put this into my code as a workaround:
The text was updated successfully, but these errors were encountered: