Skip to main content

dynamic_update_into_uninit

Function dynamic_update_into_uninit 

Source
pub unsafe fn dynamic_update_into_uninit<'a, T, I>(
    plan: &DynamicUpdateSlicePlan,
    dest: &'a mut RawStridedMut<'a, MaybeUninit<T>>,
    operand: &RawStridedRef<'_, T>,
    update: &RawStridedRef<'_, T>,
    starts: &RawStridedRef<'_, I>,
    exec: Exec<'_>,
) -> Result<()>
where T: Copy + Send + Sync, I: GatherIndex,
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. Copy the operand and overwrite its selected window.

§Examples

use strided_basic::{RawStridedRef, RawStridedMut};
use strided_basic::execution::*;
use core::mem::MaybeUninit;
use strided_basic::DynamicUpdateSlicePlan;
let plan = DynamicUpdateSlicePlan::compile(&[3], &[1], &[1], &[1], &[1], &[1], &[3], &[1]).unwrap();
let src = RawStridedRef::new(&[1_i32, 2, 3], &[3], &[1], 0).unwrap();
let update = RawStridedRef::new(&[9_i32], &[1], &[1], 0).unwrap();
let starts = RawStridedRef::new(&[1_i32], &[1], &[1], 0).unwrap();
let mut values = [MaybeUninit::<i32>::uninit(); 3];
let mut dst = RawStridedMut::new(&mut values, &[3], &[1], 0).unwrap();
// SAFETY: all inputs are initialized and disjoint from the matching output.
unsafe { dynamic_update_into_uninit(&plan, &mut dst, &src, &update, &starts, strided_basic::Exec::serial()) }.unwrap();
assert_eq!(unsafe { values[1].assume_init() }, 9);

§Errors

Returns StridedError::PlanLayoutMismatch when the destination, operand, update, or start view does not carry the plan’s compiled extents and strides, before any destination write. The clamped update window is preflighted next, still before any destination write, and rejects a window that does not fit isize: an empty destination returns before that offset arithmetic, and a non-empty one carries the bounds its constructor validated, so a checked view never reaches that rejection. Out-of-range start values are clamped, not rejected.