#[cfg(feature = "views")]
use super::ArrowBindingView;
#[cfg(feature = "views")]
impl<T> ArrowBindingView for Option<T>
where
T: ArrowBindingView,
{
type Array = T::Array;
type View<'a>
= Option<T::View<'a>>
where
Self: 'a;
fn get_view(
array: &Self::Array,
index: usize,
) -> Result<Self::View<'_>, crate::schema::ViewAccessError> {
use arrow_array::Array;
if index >= array.len() {
return Err(crate::schema::ViewAccessError::OutOfBounds {
index,
len: array.len(),
field_name: None,
});
}
if array.is_null(index) {
return Ok(None);
}
T::get_view(array, index).map(Some)
}
}