Hmm, that's implemented with catch_unwind; I thought there was a newer one that did it by conditionally panicking in Drop. (To take advantage of the built-in panic-while-unwinding-aborts behaviour.)
now I’ve looked into replace_with it enough to find out that it leaks memory: (miri confirms) (Edit: it was not a memory leak, but miri isn’t happy nontheless)
Edit2: I’m not seeing any UB anymore in the replace_with crate but either their source or Miri has to be wrong. ⟶ for anyone interested