Applies a unary infallible function to each value in an array, producing a new primitive array. # Null Handling See [`Self::unary`] for more information on null handling. # Example: create an [`Int16Array`] from an [`ArrayAccessor`] with item type `&[u8]` ``` use arrow_array::{Array, FixedSizeBinaryArray, Int16Array}; let input_arg = vec![ vec![1, 0], vec![2, 0], vec![3, 0] ]; let arr = FixedSi
(left: U, mut op: F)
| 1097 | /// assert_eq!(c, Int16Array::from(vec![Some(1i16), Some(2i16), Some(3i16)])); |
| 1098 | /// ``` |
| 1099 | pub fn from_unary<U: ArrayAccessor, F>(left: U, mut op: F) -> Self |
| 1100 | where |
| 1101 | F: FnMut(U::Item) -> T::Native, |
| 1102 | { |
| 1103 | let nulls = left.logical_nulls(); |
| 1104 | let buffer: Vec<_> = (0..left.len()) |
| 1105 | // SAFETY: i in range 0..left.len() |
| 1106 | .map(|i| op(unsafe { left.value_unchecked(i) })) |
| 1107 | .collect(); |
| 1108 | PrimitiveArray::new(buffer.into(), nulls) |
| 1109 | } |
| 1110 | |
| 1111 | /// Returns a `PrimitiveBuilder` for this array, suitable for mutating values |
| 1112 | /// in place. |
nothing calls this directly
no test coverage detected