Open
Description
To prevent users from unwittingly allocating structs that they aren't aware need to have their Drop
methods run, the alloc*
and try_alloc*
methods should add the type constraint T: !Drop
, and have pub unsafe fn *_unchecked
versions for use when the user can't meet that constraint.
It might also be useful to have a wrapper which had a Vec
or LinkedList<*mut dyn Any> droppables
; then, the unsafe methods would be replaced with alloc_*_droppable
methods that pushed the allocated pointer onto self.droppables
, and then the wrapper's impl Drop
would call self.droppables.into_iter().rev().for_each(mem::drop_in_place)
.
Metadata
Metadata
Assignees
Labels
No labels