in midst of refactor

This commit is contained in:
2024-04-29 21:46:42 +02:00
parent ed0d64d52e
commit aa3f7e99ab
221 changed files with 5431 additions and 685 deletions

View File

@@ -0,0 +1,11 @@
//! Map over a `&mut` and return an additional value
/// A variation on [take_mut::take] that allows the callback to return a value
pub fn take_with_output<T, U>(src: &mut T, cb: impl FnOnce(T) -> (T, U)) -> U {
take_mut::scoped::scope(|scope| {
let (old, hole) = scope.take(src);
let (new, out) = cb(old);
hole.fill(new);
out
})
}