pub enum CaptureKind {
Immutable,
OwnedMutable,
Shared,
}Expand description
Storage discipline for a closure capture.
Each capture index i has exactly one CaptureKind. The three kinds
are mutually exclusive and map to three mutually-exclusive bitmasks
on ClosureLayout (heap_capture_mask, owned_mutable_capture_mask,
shared_capture_mask).
Immutable—letby-move/copy captures. The slot’s width followscapture_types[i]viaFieldKind; reads and writes go throughsuper::closure_raw::read_capture_as_value_bitsandsuper::closure_raw::write_capture_typedas today. If the underlying field kind isPtr, the slot owns one heap-refcount share (participates inheap_capture_mask).OwnedMutable—let mutby-move captures. The 8-byte slot holds*mut ValueWordobtained fromBox::into_raw(Box::new(...)). Exactly one closure owns the box; Drop reclaims it withBox::from_raw. The interiorValueWordcan itself carry heap refcount shares — those must be dropped before the box is freed.Shared—varcaptures shared across nested closures. The 8-byte slot holds*const SharedCellobtained fromArc::into_raw(Arc::new(Mutex::new(...))). Each slot counts as oneArcstrong share; reads/writes take the parking_lot mutex.
Variants§
Immutable
let binding: value in slot, width per FieldKind.
OwnedMutable
let mut binding: Ptr slot holds *mut ValueWord (Box cell).
var binding: Ptr slot holds *const SharedCell
(Arc<parking_lot::Mutex<ValueWord>> via Arc::into_raw).
Trait Implementations§
Source§impl Clone for CaptureKind
impl Clone for CaptureKind
Source§fn clone(&self) -> CaptureKind
fn clone(&self) -> CaptureKind
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CaptureKind
impl Debug for CaptureKind
Source§impl Hash for CaptureKind
impl Hash for CaptureKind
Source§impl PartialEq for CaptureKind
impl PartialEq for CaptureKind
Source§fn eq(&self, other: &CaptureKind) -> bool
fn eq(&self, other: &CaptureKind) -> bool
Tests for
self and other values to be equal, and is used by ==.impl Copy for CaptureKind
impl Eq for CaptureKind
impl StructuralPartialEq for CaptureKind
Auto Trait Implementations§
impl Freeze for CaptureKind
impl RefUnwindSafe for CaptureKind
impl Send for CaptureKind
impl Sync for CaptureKind
impl Unpin for CaptureKind
impl UnsafeUnpin for CaptureKind
impl UnwindSafe for CaptureKind
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more