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
thread 'test' panicked at 'already borrowed: BorrowMutError', .../typed-arena-2.0.2/src/lib.rs:194:38
For additional context, I wanted to represent a rose-tree-like data structure and save on allocations, constructing it from another data structure, but in effect I have to collect all my iterators into Vecs before alloc_extend and that kinda defeats the purpose.
Now, I understand why it panics. The question is, can we make it not panic? Seems like it should be possible in principle (although tricky)
The text was updated successfully, but these errors were encountered:
A simple(-ish) approach may be to change ChunkList::current to be an Option, take it out at the start of alloc_extend. If the iterator tries to allocate, make a new Vec for current. At the end of alloc_extend either put the taken out current back (if current is None) or push it to rest. Depending on the allocation pattern, this may be rather wasteful, but it arguably beats an undocumented panic.
TL;DR: see subject.
A slightly convoluted example:
Expectation: the code works.
Reality:
For additional context, I wanted to represent a rose-tree-like data structure and save on allocations, constructing it from another data structure, but in effect I have to
collect
all my iterators intoVec
s beforealloc_extend
and that kinda defeats the purpose.Now, I understand why it panics. The question is, can we make it not panic? Seems like it should be possible in principle (although tricky)
The text was updated successfully, but these errors were encountered: