Skip to main content

drop_owned_mutable_capture

Function drop_owned_mutable_capture 

Source
pub unsafe fn drop_owned_mutable_capture(
    layout: &ClosureLayout,
    base: *mut u8,
    i: usize,
)
Expand description

Drop the OwnedMutable capture at index i of a closure block.

Reads the typed *mut T from the slot at layout.heap_capture_offset(i), dispatches on layout.capture_inner_kind(i), and reclaims the box via Box::from_raw. For FieldKind::Ptr the interior bits carry one heap-refcount share that is released via [release_raw_value_bits] BEFORE the box is freed — mirroring the immutable-Ptr semantics that heap_capture_mask enforces for non-mutable captures.

§Safety

  • base must point to a live TypedClosureHeader block whose layout matches layout and has at least i + 1 captures.
  • layout.capture_kinds[i] must be CaptureKind::OwnedMutable.
  • The slot at layout.heap_capture_offset(i) must contain a non-null pointer obtained from the matching alloc_owned_mutable_<kind> for the interior FieldKind, or it may be null (which is a no-op).
  • The block must currently be in the refcount-zero teardown phase — no other thread may concurrently access this slot.