Convert to an owned Vec, copying data if zero-copy.
(&self)
| 74 | |
| 75 | /// Convert to an owned Vec, copying data if zero-copy. |
| 76 | pub fn to_vec(&self) -> Vec<T> { |
| 77 | match self { |
| 78 | Self::Owned(v) => v.clone(), |
| 79 | Self::ZeroCopy { ptr, len, .. } => { |
| 80 | let slice = unsafe { std::slice::from_raw_parts(*ptr, *len) }; |
| 81 | slice.to_vec() |
| 82 | } |
| 83 | } |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | impl<T: Copy> std::ops::Deref for DenseArray<T> { |