vortex_array/
accessor.rs

1use vortex_error::VortexResult;
2
3use crate::Array;
4
5/// Trait for arrays that support iterative access to their elements.
6pub trait ArrayAccessor<Item: ?Sized>: Array {
7    /// Iterate over each element of the array, in-order.
8    ///
9    /// The function `f` will be passed an [`Iterator`], it can call [`next`][Iterator::next] on the
10    /// iterator [`len`][crate::Array::len] times. Iterator elements are `Option` types,
11    /// regardless of the nullability of the underlying array data.
12    fn with_iterator<F, R>(&self, f: F) -> VortexResult<R>
13    where
14        F: for<'a> FnOnce(&mut dyn Iterator<Item = Option<&'a Item>>) -> R;
15}