Migrate data-stack-backed storage to the heap, preserving all values. Returns the data stack base pointer for `DataStack::pop()`. Returns `None` if already heap-backed.
(&mut self)
| 201 | /// Returns the data stack base pointer for `DataStack::pop()`. |
| 202 | /// Returns `None` if already heap-backed. |
| 203 | fn materialize_to_heap(&mut self) -> Option<*mut u8> { |
| 204 | if let LocalsPlusData::DataStack { ptr, capacity } = &self.data { |
| 205 | let base = *ptr as *mut u8; |
| 206 | let heap_data = unsafe { core::slice::from_raw_parts(*ptr, *capacity) } |
| 207 | .to_vec() |
| 208 | .into_boxed_slice(); |
| 209 | self.data = LocalsPlusData::Heap(heap_data); |
| 210 | Some(base) |
| 211 | } else { |
| 212 | None |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | /// Drop all contained values without freeing the backing storage. |
| 217 | fn drop_values(&mut self) { |
no test coverage detected