vortex_array/
accessor.rs

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