YichiZhang0613 opened a new issue, #5430:
URL: https://github.com/apache/arrow-rs/issues/5430

   I noticed a possible panic due to inconsistency between comments and code 
implementation in arrow-rs/arrow-array/src/array/union_array.rs. The details 
can be found in the following code. 
   I think this function should check whether index is out of bounds as your 
comment read before it is used as self.type_ids[index], which could avoid 
unnecessary panic.
   ```rust
      /// # Panics
       ///
       /// Panics if `index` is greater than the length of the array.
       pub fn type_id(&self, index: usize) -> i8 {
           self.type_ids[index]
       }
   ```
   By the way, I think it would be more complete if  the comment is modified to 
`Panics if index is greater than  or equal to the length of the array.` instead 
of `Panics if index is greater than the length of the array.`
   ```rust
       /// # Panics
       ///
       /// Panics if `index` is greater than the length of the array.
       pub fn value_offset(&self, index: usize) -> usize {
           assert!(index < self.len());
   ```


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