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.
To Reproduce
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())]);
// Array reference 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).
Describe the bug
arrow::array::FixedSizeBinaryArrayimplementsFrom<Vec<&[u8]>>,From<Vec<&[u8; N]>>, andFrom<Vec<Option<&[u8]>>>. Each of these implementations panics when given inputs that cannot truly be converted to aFixedSizeBinaryArray.From the Rust docs for
From:To Reproduce
Expected behavior
The presence of
Fromimplementations implies that an infallible conversion is possible, so it's expected that these calls would produce some validFixedBinarySizeArray(whether that could be done in a coherent fashion is unlikely - realistically these should beTryFromimplementations).