Description
This calls the "drop glue" for a given type without having to explicitly read it out onto the stack to be dropped. All types have a drop glue implementation, which involves calling the types Drop impl (if it exists), and the recursively running drop glue on its fields.
drop_in_place is both a performance improvement (in the case of e.g. Vec, it avoids ptr::reading the elements out), and a semantic necessity (in the case of DSTs, it's impossible to ptr::read the value, but the vtable always contains a drop glue impl).
It is currently exposed in the ptr
module because it's maximally expressive to take a *mut
and because "that's what the intrinsic took" at the time it was exposed outside of std::intrinsics. It may be desirable to instead expose it in mem
to parallel mem::drop
, and require an &mut
. For most cases you probably already have an &mut anyway, and it's trivial to upgrade.