tustvold commented on code in PR #3260:
URL: https://github.com/apache/arrow-rs/pull/3260#discussion_r1038380161
##########
arrow-array/src/array/primitive_array.rs:
##########
@@ -475,12 +492,29 @@ impl<T: ArrowPrimitiveType> PrimitiveArray<T> {
O: ArrowPrimitiveType,
F: Fn(T::Native) -> Result<O::Native, E>,
{
- let data = self.data();
- let len = self.len();
- let null_count = self.null_count();
+ PrimitiveArray::try_from_unary(self, op)
+ }
+
+ /// Creates a [`PrimitiveArray`] from the result of evaluating an fallible
+ /// function `op` for every valid element in `array`.
+ ///
+ /// ```
+ /// use arrow_array::{Int32Array, StringArray};
+ /// let array = StringArray::from(vec![Some("12"), Some("45"), None]);
+ /// let r = Int32Array::try_from_unary(&array, |v| v.parse()).unwrap();
Review Comment:
I think this is pretty cool
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]