pub fn search_path<'a>(
    prefix: &'a Path,
    path_val: &'a str,
) -> Result<impl Iterator<Item = PathBuf> + 'a, PatternError> {
    let globs = path_val
        .split(':')
        .map(move |dir: &str| {
            let full_prefix = Path::new(dir).join(prefix);

            // todo: handle pattern errors
            let found = search_prefix(full_prefix.as_path())
                .unwrap()
                .into_iter()
                .filter(|path| !path.is_dir() && path.executable())
                .map(|path| match path.components().last() {
                    Some(component) => PathBuf::from(component.as_os_str()),
                    None => path,
                });

            found
        })
        .flatten();

    Ok(globs)
}
/// Searches the directories on the system's PATH environment variable for
/// paths with the given prefix. The returned paths are stripped of any parent
/// directories.
///
/// If any error is encountered while reading a file, that file is ignored.
Searches the directories on the system's PATH environment variable for
paths with the given prefix. The returned paths are stripped of any parent
directories.

If any error is encountered while reading a file, that file is ignored.
Searches the directories on the system ' s PATH environment variable for paths with the given prefix . The returned paths are stripped of any parent directories . If any error is encountered while reading a file that file is ignored .
pub fn search_path<'a>(
    prefix: &'a Path,
    path_val: &'a str,
) -> Result<impl Iterator<Item = PathBuf> + 'a, PatternError> {
    let globs = path_val
        .split(':')
        .map(move |dir: &str| {
            let full_prefix = Path::new(dir).join(prefix);
            // todo: handle pattern errors
            let found = search_prefix(full_prefix.as_path())
                .unwrap()
                .into_iter()
                .filter(|path| !path.is_dir() && path.executable())
                .map(|path| match path.components().last() {
                    Some(component) => PathBuf::from(component.as_os_str()),
                    None => path,
                });
            found
        })
        .flatten();
    Ok(globs)
}
pub fn search_path < ' a > ( prefix : & ' a Path , path_val : & ' a str , ) -> Result < impl Iterator < Item = PathBuf > + ' a , PatternError > { let globs = path_val . split ( ':' ) . map ( move | dir : & str | { let full_prefix = Path :: new ( dir ) . join ( prefix ) ; // todo: handle pattern errors let found = search_prefix ( full_prefix . as_path ( ) ) . unwrap ( ) . into_iter ( ) . filter ( | path | ! path . is_dir ( ) && path . executable ( ) ) . map ( | path | match path . components ( ) . last ( ) { Some ( component ) => PathBuf :: from ( component . as_os_str ( ) ) , None => path , } ) ; found } ) . flatten ( ) ; Ok ( globs ) }
Searches the directories on the system's PATH environment variable for
paths with the given prefix.
Searches the directories on the system ' s PATH environment variable for paths with the given prefix .
prefix
&'a Path
path_val
&'a str