dirx 0.1.0

Creates an in-memory index of all the files in a directory tree, and allows efficient scanning of only those files that have been modified since the index got created
Documentation
use crate::index::DirIndex;
use crate::index::IndexedFile;
use std::marker::PhantomData;
use std::path::PathBuf;

#[derive(Debug)]
pub(crate) struct ExtractStale<T> {
    next: usize,
    phantom: PhantomData<T>,
}

impl<T> ExtractStale<T> {
    pub(crate) fn new() -> Self {
        Self {
            next: 0,
            phantom: PhantomData,
        }
    }

    pub(crate) fn next(&mut self, index: &mut DirIndex<T>) -> Option<(PathBuf, IndexedFile<T>)> {
        while let Some((_, file)) = index.entries.get_index(self.next) {
            if file.stale {
                return index.entries.swap_remove_index(self.next);
            } else {
                self.next += 1;
            }
        }
        None
    }
}