MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / to_vec

Method to_vec

nodedb-graph/src/csr/dense_array.rs:76–84  ·  view source on GitHub ↗

Convert to an owned Vec, copying data if zero-copy.

(&self)

Source from the content-addressed store, hash-verified

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
87impl<T: Copy> std::ops::Deref for DenseArray<T> {

Calls 1

cloneMethod · 0.45