viirya commented on code in PR #1990:
URL: https://github.com/apache/arrow-rs/pull/1990#discussion_r914509485


##########
arrow/src/compute/kernels/arity.rs:
##########
@@ -78,10 +83,114 @@ where
     PrimitiveArray::<O>::from(data)
 }
 
+/// A helper function that applies an unary function to a dictionary array 
with primitive value type.
+#[allow(clippy::redundant_closure)]
+fn unary_dict<K, F, T>(array: &DictionaryArray<K>, op: F) -> Result<ArrayRef>
+where
+    K: ArrowNumericType,
+    T: ArrowPrimitiveType,
+    F: Fn(T::Native) -> T::Native,
+{
+    let dict_values = array
+        .values()
+        .as_any()
+        .downcast_ref::<PrimitiveArray<T>>()
+        .unwrap();
+
+    let values = dict_values
+        .iter()
+        .map(|v| v.map(|value| op(value)))

Review Comment:
   Although the clippy complains about this
   ```rust
   error: redundant closure
      --> arrow/src/compute/kernels/arity.rs:101:24
       |
   101 |         .map(|v| v.map(|value| op(value)))
       |                        ^^^^^^^^^^^^^^^^^ help: replace the closure 
with the function itself: `op`
       |
   ```
   
   But I cannot follow the suggestion. The compiler fails to compile because 
`op` cannot moved.



-- 
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]

Reply via email to