find_matching_recursively_in_dir

Function find_matching_recursively_in_dir 

Source
pub fn find_matching_recursively_in_dir(
    dir: &Path,
    matching_file_fn: impl Fn(&DirEntry) -> bool,
    skip_dir_fn: impl Fn(&DirEntry) -> bool,
) -> Result<Vec<PathBuf>>
Expand description

Recursively find files matching a predicate (breadth-first)

Performs a breadth-first traversal starting at dir, skipping directories for which skip_dir_fn returns true, and collecting file paths for which matching_file_fn returns true.

§Errors

  • A directory cannot be read.
  • File type metadata for an entry cannot be determined.
  • Any underlying filesystem I/O error occurs during traversal.

§Performance

Uses an in-memory queue (BFS). For extremely deep trees consider a streaming iterator variant; current implementation favors simplicity over incremental output.

§Future Work

  • Provide an iterator adapter (impl Iterator<Item = PathBuf>), avoiding collecting all results.
  • Optional parallel traversal behind a feature flag for large repositories.