MCPcopy Create free account
hub / github.com/apache/arrow-rs / from

Method from

arrow-buffer/src/buffer/mutable.rs:880–897  ·  view source on GitHub ↗
(value: Vec<T>)

Source from the content-addressed store, hash-verified

878
879impl<T: ArrowNativeType> From<Vec<T>> for MutableBuffer {
880 fn from(value: Vec<T>) -> Self {
881 // Safety
882 // Vec::as_ptr guaranteed to not be null and ArrowNativeType are trivially transmutable
883 let data = unsafe { NonNull::new_unchecked(value.as_ptr() as _) };
884 let len = value.len() * mem::size_of::<T>();
885 // Safety
886 // Vec guaranteed to have a valid layout matching that of `Layout::array`
887 // This is based on `RawVec::current_memory`
888 let layout = unsafe { Layout::array::<T>(value.capacity()).unwrap_unchecked() };
889 mem::forget(value);
890 Self {
891 data,
892 len,
893 layout,
894 #[cfg(feature = "pool")]
895 reservation: std::sync::Mutex::new(None),
896 }
897 }
898}
899
900impl MutableBuffer {

Callers

nothing calls this directly

Calls 3

as_ptrMethod · 0.45
lenMethod · 0.45
capacityMethod · 0.45

Tested by

no test coverage detected