use super::proxy::Proxy;
use super::LazyVec;
use serde::de::DeserializeOwned;
use serde::Serialize;
pub struct LazyVecIt<'a, V> {
tree: &'a LazyVec<V>,
global_idx: usize,
}
impl<'a, V> Iterator for LazyVecIt<'a, V>
where
V: Serialize + DeserializeOwned,
{
type Item = Proxy<'a, V>;
fn next(&mut self) -> Option<Self::Item> {
let out = self.tree.get(self.global_idx);
self.global_idx = self.global_idx.saturating_add(1);
out
}
}
impl<'a, V> LazyVecIt<'a, V>
where
V: Serialize + DeserializeOwned,
{
pub(crate) fn new(tree: &'a LazyVec<V>) -> Self {
LazyVecIt {
tree,
global_idx: 0,
}
}
}