Applies a unary and infallible function to the array in place if possible. # Buffer Reuse If the underlying buffers are not shared with other arrays, mutates the underlying buffer in place, without allocating. If the underlying buffer is shared, returns Err(self) # Null Handling See [`Self::unary`] for more information on null handling. # Example ```rust # use arrow_array::{Int32Array, typ
(self, op: F)
| 947 | /// assert_eq!(c, Int32Array::from(vec![Some(11), Some(15), None])); |
| 948 | /// ``` |
| 949 | pub fn unary_mut<F>(self, op: F) -> Result<PrimitiveArray<T>, PrimitiveArray<T>> |
| 950 | where |
| 951 | F: Fn(T::Native) -> T::Native, |
| 952 | { |
| 953 | let mut builder = self.into_builder()?; |
| 954 | builder |
| 955 | .values_slice_mut() |
| 956 | .iter_mut() |
| 957 | .for_each(|v| *v = op(*v)); |
| 958 | Ok(builder.finish()) |
| 959 | } |
| 960 | |
| 961 | /// Applies a unary fallible function to all valid values in a primitive |
| 962 | /// array, producing a new array of potentially different type. |