pub fn find_filenames<Predicate: FnMut(&Path) -> bool>(
    paths: &[impl AsRef<Path>],
    mut is_file_desired: Predicate,
) -> anyhow::Result<Vec<String>> {
    let mut result = vec![];

    for s in paths {
        let path = s.as_ref();
        if !path.exists() {
            bail!("No such file or directory '{}'", path.to_string_lossy())
        }
        if path.is_file() && is_file_desired(path) {
            result.push(path_to_string(path)?);
            continue;
        }
        if !path.is_dir() {
            continue;
        }
        for entry in walkdir::WalkDir::new(path)
            .follow_links(true)
            .into_iter()
            .filter_map(|e| e.ok())
        {
            let entry_path = entry.path();
            if !entry.file_type().is_file() || !is_file_desired(entry_path) {
                continue;
            }

            result.push(path_to_string(entry_path)?);
        }
    }
    Ok(result)
}
/// - For each directory in `paths`, it will return all files that satisfy the predicate
/// - Any file explicitly passed in `paths`, it will include that file in the result, regardless
///   of the file extension
For each directory in `paths`, it will return all files that satisfy the predicate
Any file explicitly passed in `paths`, it will include that file in the result, regardless
of the file extension
For each directory in ` paths ` it will return all files that satisfy the predicate Any file explicitly passed in ` paths ` it will include that file in the result regardless of the file extension
pub fn find_filenames<Predicate: FnMut(&Path) -> bool>(
    paths: &[impl AsRef<Path>],
    mut is_file_desired: Predicate,
) -> anyhow::Result<Vec<String>> {
    let mut result = vec![];
    for s in paths {
        let path = s.as_ref();
        if !path.exists() {
            bail!("No such file or directory '{}'", path.to_string_lossy())
        }
        if path.is_file() && is_file_desired(path) {
            result.push(path_to_string(path)?);
            continue;
        }
        if !path.is_dir() {
            continue;
        }
        for entry in walkdir::WalkDir::new(path)
            .follow_links(true)
            .into_iter()
            .filter_map(|e| e.ok())
        {
            let entry_path = entry.path();
            if !entry.file_type().is_file() || !is_file_desired(entry_path) {
                continue;
            }
            result.push(path_to_string(entry_path)?);
        }
    }
    Ok(result)
}
pub fn find_filenames < Predicate : FnMut ( & Path ) -> bool > ( paths : & [ impl AsRef < Path > ] , mut is_file_desired : Predicate , ) -> anyhow :: Result < Vec < String > > { let mut result = vec ! [ ] ; for s in paths { let path = s . as_ref ( ) ; if ! path . exists ( ) { bail ! ( " " path to_string_lossy ( ) ) } if path . is_file ( ) && is_file_desired ( path ) { result . push ( path_to_string ( path ) ? ) ; continue ; } if ! path . is_dir ( ) { continue ; } for entry in walkdir :: WalkDir :: new ( path ) . follow_links ( true ) . into_iter ( ) . filter_map ( | e | e . ok ( ) ) { let entry_path = entry . path ( ) ; if ! entry . file_type ( ) . is_file ( ) || ! is_file_desired ( entry_path ) { continue ; } result . push ( path_to_string ( entry_path ) ? ) ; } } Ok ( result ) }
For each directory in `paths`, it will return all files that satisfy the predicate
 Any file explicitly passed in `paths`, it will include that file in the result, regardless
of the file extension
For each directory in ` paths ` it will return all files that satisfy the predicate Any file explicitly passed in ` paths ` it will include that file in the result regardless of the file extension
paths
&[impl AsRef<Path>]
is_file_desired
Predicate