apply_include_patterns

Function apply_include_patterns 

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

Apply include patterns to a collection

Keeps only items whose paths match at least one include 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 include 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_include_patterns;
use infiniloom_engine::types::RepoFile;

let mut files: Vec<RepoFile> = vec![/* ... */];
let include = vec!["*.rs".to_string(), "*.ts".to_string()];

apply_include_patterns(&mut files, &include, |f| &f.relative_path);