pub fn into_vec<T>(data: &DoraArray) -> Result<Vec<T>, Report>Expand description
Tries to convert the given payload into a Vec of integers or floats.
The array’s element type is cast to T per element via num::NumCast,
so the source and target types need not match (e.g. a UInt64Array
into a Vec<f64>).
§Errors
Returns an error if the array contains any null values (consistent
with every other TryFrom<&DoraArray> impl in this crate), if the
array’s data type is not a supported integer or float type, or if any
element cannot be represented in T (an out-of-range cast).
use dora_arrow_convert::{IntoArrow, into_vec};
// Values are cast element-wise to the requested target type.
let data = vec![1u64, 2, 3].into_arrow();
assert_eq!(into_vec::<u64>(&data).ok(), Some(vec![1, 2, 3]));
assert_eq!(into_vec::<f64>(&data).ok(), Some(vec![1.0, 2.0, 3.0]));
// Unsupported (non-numeric) array types are rejected.
let strings = vec!["a".to_string(), "b".to_string()].into_arrow();
assert!(into_vec::<u64>(&strings).is_err());