Function replace

Source
pub(super) fn replace<T, R>(v: &mut T, change: impl FnOnce(T) -> (T, R)) -> R
Expand description

This replaces the value behind the v unique reference by calling the relevant function, and returns a result obtained along the way.

If a panic occurs in the change closure, the entire process will be aborted.