alamb commented on a change in pull request #9588:
URL: https://github.com/apache/arrow/pull/9588#discussion_r587849026



##########
File path: rust/arrow/src/array/array_binary.rs
##########
@@ -258,6 +258,8 @@ where
             }
         }
 
+        // calculate actual data_len, which may be different from the 
iterator's upper bound
+        let data_len = offsets.len() - 1;

Review comment:
       https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.size_hint  
says
   
   > It is not enforced that an iterator implementation yields the declared 
number of elements. A buggy iterator may yield less than the lower bound or 
more than the upper bound of elements.
   
   > size_hint() is primarily intended to be used for optimizations such as 
reserving space for the elements of the iterator, but must not be trusted to 
e.g., omit bounds checks in unsafe code. An incorrect implementation of 
size_hint() should not lead to memory safety violations.
   
   I figured i would paste that into this PR as I had looked it up to satisfy 
my own curiosity




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

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to