too-many-lists
too-many-lists copied to clipboard
Clarifying where and why pop deallocates first node from the heap
In https://rust-unofficial.github.io/too-many-lists/first-pop.html I would appreciate clarification on exactly where and why the first node on the list gets deallocated from the heap by pop after pop uses mem::replace or take. I'm loving your tutorial and I'm hoping to get more clarity on Rust's deallocation strategies.
I'm actually not 100% certain, because iirc this code uses the obscure and 100% special DerefMove semantics of Box that allow the allocation to be partially moved out of. I would expect the deallocation to happen at the end of the scope, but wouldn't be surprised if it happens earlier.