Skip to main content

dynamic_slice_into_uninit

Function dynamic_slice_into_uninit 

Source
pub unsafe fn dynamic_slice_into_uninit<T, I>(
    plan: &DynamicSlicePlan,
    dest: &mut RawStridedMut<'_, MaybeUninit<T>>,
    operand: &RawStridedRef<'_, T>,
    starts: &RawStridedRef<'_, I>,
) -> Result<()>
Expand description

Full-overwrite indexed replay for an operation-family adapter.

§Safety

The adapter must reject input/output overlap before creating the input references. All descriptor allocation and initialization contracts must remain valid for the call. Output slots may be uninitialized; the owning plan retains its checked layout/index validation and private initialization receipt. No initialized reference to the output backing may be formed.

§Examples

use strided_basic::execution::*;
// SAFETY: the example supplies matching bounded layouts and disjoint storage.
use strided_basic::{DynamicSlicePlan, RawStridedRef, RawStridedMut};
use core::mem::MaybeUninit;
let plan = DynamicSlicePlan::compile(&[3], &[1], &[1], &[1], &[2], &[1], &[2]).unwrap();
let src = RawStridedRef::new(&[1_i32, 2, 3], &[3], &[1], 0).unwrap();
let starts = RawStridedRef::new(&[1_i32], &[1], &[1], 0).unwrap();
let mut values = [MaybeUninit::<i32>::uninit(); 2];
let mut dst = RawStridedMut::new(&mut values, &[2], &[1], 0).unwrap();
unsafe { dynamic_slice_into_uninit(&plan, &mut dst, &src, &starts) }.unwrap();
assert_eq!(unsafe { values[1].assume_init() }, 3);

§Errors

Forwards errors from the owning kernel or callback; callers must still satisfy the safety contract before invoking this prevalidated entry.