T: Default, or you can otherwise provide a sensible empty/sentinel value to temporarily fill in the place, you can use
mem::swap() to move the value out and then assign it back in.
If there's no such sensible sentinel value, then I believe it is not possible to implement this soundly. You could technically use
ptr::write(), although I would not recommend doing this, because I don't see how it is at all possible to get it right in the presence of panicking, at least not as-is.
The problem with the usual "hole" approach (a temporary RAII guard that puts a valid value into the reference when a panic occurs) is that the original value will have already been consumed by the time the panic occurs, since it is passed to the function by value. So there's nothing to put back in that case. You could instead try asserting that the function does not panic, although there isn't a 100% reliable way for achieving that.
The safe and the unsound approach (along with the double free) described above are demonstrated in this Playground.