rluvaton commented on PR #8728:
URL: https://github.com/apache/arrow-rs/pull/8728#issuecomment-3458547097

   and this test example where the iterator is mutated rather than consumed:
   ```rs
   #[test]
   fn assert_any() {
       struct AnyOp {
           false_count: usize,
       }
   
       impl MutatingArrayIteratorOp for AnyOp {
           type Output = CallTrackingWithInputType<bool>;
   
           fn name(&self) -> String {
               format!("any with {} false returned", self.false_count)
           }
   
           fn get_value<T: SharedBetweenArrayIterAndSliceIter>(
               &self,
               iter: &mut T,
           ) -> Self::Output {
                        // track the cb calls
               let mut items = Vec::with_capacity(iter.len());
   
                        // track the number of false we returned from the any 
callback
               let mut count = 0;
   
                        // save the any result to make sure we return the same 
value
               let res = iter.any(|item| {
   
                                // in any we also want to track the callback 
calls are the same, so we save that as well 
                   items.push(item);
   
                                // Allow for different amount of false to be 
returned before true
                   if count < self.false_count {
                       count += 1;
                       false
                   } else {
                       true
                   }
               });
   
                        // Return the data we assert on
               CallTrackingWithInputType {
                                // we test that we get called with the same 
arguments
                   calls: items,
                                // We also test that the returned value from 
any is correct
                   result: res,
               }
           }
       }
   
        // we want to test both when we find the value in the 1st call (always 
true - false count is 0)
       // when we find after 2nd and 3rd calls
        // and when we never find
       for false_count in [0, 1, 2, usize::MAX] {
           assert_array_iterator_cases_mutate(AnyOp { false_count });
       }
   }
   ```


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