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

   **Describe the bug**
   `arrow::array::FixedSizeBinaryArray` implements `From<Vec<&[u8]>>`, 
`From<Vec<&[u8; N]>>`, and `From<Vec<Option<&[u8]>>>`. Each of these 
implementations panics when given inputs that cannot truly be converted to a 
`FixedSizeBinaryArray`.
   
   From the Rust docs for `From`: 
   > Note: This trait must not fail. The From trait is intended for perfect 
conversions. If the conversion can fail or is not perfect, use 
[TryFrom](https://doc.rust-lang.org/std/convert/trait.TryFrom.html).
   
   **To Reproduce**
   ```rs
   use arrow_array::FixedSizeBinaryArray;
   
   fn main() {
        // Slices of different sizes: panics!
        let a1 = FixedSizeBinaryArray::from(vec![[1].as_slice(), [1, 
2].as_slice()]);
        let a2 = FixedSizeBinaryArray::from(vec![Some([1].as_slice()), 
Some([1,2].as_slice())]);
        // Slice of too large a size: panics! (admittedly a corner case)
        let arr = vec![0; i32::MAX as usize + 1];
        let slice = <&[u8; i32::MAX as usize + 
1]>::try_from(arr.as_slice()).unwrap();
        let a3 = FixedSizeBinaryArray::from(vec![slice]);
        dbg!(a1, a2, a3);
   }
   ```
   
   **Expected behavior**
   The presence of `From` implementations implies that an infallible conversion 
is possible, so it's expected that these calls would produce some valid 
`FixedBinarySizeArray` (whether that could be done in a coherent fashion is 
unlikely - realistically these should be `TryFrom` implementations).


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