parallel_processor/utils/
replace_with_async.rs

1use std::future::Future;
2use std::ptr;
3
4pub async fn replace_with_async<'a, R, F: Future<Output = R> + 'a, C: FnOnce(R) -> F>(
5    dest: &mut R,
6    fun: C,
7) {
8    unsafe {
9        let old = ptr::read(dest);
10        let new = fun(old).await;
11        ptr::write(dest, new);
12    }
13}