use self::entry::SearchEntry; use crate::{config::SearchEntryConfig, project::ProjectItem}; pub mod entry; type EntryIter = std::vec::IntoIter; pub struct Search { iter: EntryIter, curr: Option, } impl std::fmt::Debug for Search { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_struct("Projects") .field("paths_iter", &self.iter) .finish_non_exhaustive() } } impl From for Search where T: IntoIterator, { fn from(value: T) -> Self { Self { iter: value.into_iter(), curr: None, } } } impl Iterator for Search { type Item = ProjectItem; #[tracing::instrument] fn next(&mut self) -> Option { match self.curr.as_mut().and_then(|c| c.next()) { Some(proj) => Some(proj), None => { self.curr = Some(self.iter.next()?.into()); self.next() } } } }