apply_exclude_patterns

Function apply_exclude_patterns 

Source
pub fn apply_exclude_patterns<T, F>(
    items: &mut Vec<T>,
    patterns: &[String],
    get_path: F,
)
where F: Fn(&T) -> &str,
Expand description

Apply exclude patterns to a collection

Removes items whose paths match any exclude pattern. Uses a generic get_path function to extract the path from each item.

§Arguments

  • items - Mutable reference to collection to filter
  • patterns - List of exclude patterns
  • get_path - Function to extract path from an item

§Type Parameters

  • T - Type of items in the collection
  • F - Type of the path extraction function

§Examples

use infiniloom_engine::filtering::apply_exclude_patterns;
use infiniloom_engine::types::RepoFile;

let mut files: Vec<RepoFile> = vec![/* ... */];
let exclude = vec!["node_modules".to_string(), "*.min.js".to_string()];

apply_exclude_patterns(&mut files, &exclude, |f| &f.relative_path);