pub fn files_in_dir_ending_with(dir: &PathBuf, extension: &str) -> StatusOr<Vec<String>> {
    Ok(dir.read_dir()
        .map_err(|e| format!("Bad dir: {:?}", e))?
        .filter_map(|entry| entry.ok())
        .map(|entry| entry.file_name())
        .filter_map(|base_name| {
            let base_name_str = base_name.to_str()?;
            if !base_name_str.ends_with(extension) {
                return None;
            }
            Some(String::from(base_name_str))
        })
        .collect())
}
// Returns base names of files in dir that match .*extension
Returns base names of files in dir that match .*extension
Returns base names of files in dir that match . * extension
pub fn files_in_dir_ending_with(dir: &PathBuf, extension: &str) -> StatusOr<Vec<String>> {
    Ok(dir.read_dir()
        .map_err(|e| format!("Bad dir: {:?}", e))?
        .filter_map(|entry| entry.ok())
        .map(|entry| entry.file_name())
        .filter_map(|base_name| {
            let base_name_str = base_name.to_str()?;
            if !base_name_str.ends_with(extension) {
                return None;
            }
            Some(String::from(base_name_str))
        })
        .collect())
}
pub fn files_in_dir_ending_with ( dir : & PathBuf , extension : & str ) -> StatusOr < Vec < String > > { Ok ( dir . read_dir ( ) . map_err ( | e | format ! ( " " e ) ) ? . filter_map ( | entry | entry . ok ( ) ) . map ( | entry | entry . file_name ( ) ) . filter_map ( | base_name | { let base_name_str = base_name . to_str ( ) ? ; if ! base_name_str . ends_with ( extension ) { return None ; } Some ( String :: from ( base_name_str ) ) } ) . collect ( ) ) }
Returns base names of files in dir that match .
Returns base names of files in dir that match .
dir
&PathBuf
extension
&str
dir
&PathBuf
extension
&str