pub unsafe fn clone_stack_value(sv: &StackValue) -> StackValueExpand description
Clone a StackValue, handling reference counting for heap types.
§Cloning Strategy by Type
- Int, Float, Bool, Quotation: Bitwise copy (no heap allocation)
- String: Deep copy to a new global (refcounted) string. This is necessary because the source may be an arena-allocated string that would become invalid when the arena resets. Global strings are heap-allocated with Arc refcounting.
- Variant: Arc refcount increment (O(1), shares underlying data)
- Map: Deep clone of the HashMap and all contained values
- Closure: Deep clone of the Arc<Value> environment
- Channel: Arc refcount increment (O(1), shares underlying sender/receiver)
§Safety
The StackValue must contain valid data for its discriminant.