replace_with
replace_with copied to clipboard
Use `#[cfg(panic = "abort")]` to make `replace_with_or_abort_unchecked` safe
We can actually check for panic
being set to abort
with a built-in cfg macro. I guess this way we can make a safe version of the replace_with_or_abort_unchecked
function:
#[inline]
#[cfg(panic = "abort")]
pub fn replace_with_or_abort_unchecked<T, F: FnOnce(T) -> T>(dest: &mut T, f: F) {
unsafe { ptr::write(dest, f(ptr::read(dest))); }
}