pub fn replay_map_raw_uninit<D, S, F>(
dest: &mut RawStridedMut<'_, MaybeUninit<D>>,
src: &RawStridedRef<'_, S>,
f: F,
exec: Exec<'_>,
) -> Result<()>Expand description
dest[i] = f(src[i]) into a potentially uninitialized destination.
f cannot read the destination. On success every reachable destination
element is initialized and no other slot is written. The visit-order,
callback and allocation contract is that of replay_map_raw.
§Errors
As replay_copy_raw.
§Examples
use core::mem::MaybeUninit;
use strided_basic::{replay_map_raw_uninit, Exec, RawStridedMut, RawStridedRef};
let src = [1i32, 2, 3];
let mut storage = [MaybeUninit::<f64>::uninit(); 3];
let mut dst = RawStridedMut::new(&mut storage, &[3], &[1], 0).unwrap();
let source = RawStridedRef::new(&src, &[3], &[1], 0).unwrap();
replay_map_raw_uninit(&mut dst, &source, |s| f64::from(s) * 0.5, Exec::serial()).unwrap();
drop(dst);
// SAFETY: every reachable destination slot was initialized above.
let values: Vec<f64> = storage.iter().map(|v| unsafe { v.assume_init() }).collect();
assert_eq!(values, [0.5, 1.0, 1.5]);