fn versions_matching(dir: &Path, re: &Regex) -> Fallible<BTreeSet<Version>> {
    let contents = read_dir_eager(dir).with_context(|_| ErrorDetails::ReadDirError {
        dir: dir.to_path_buf(),
    })?;

    let versions = contents
        .filter(|(_, metadata)| metadata.is_file())
        .filter_map(|(entry, _)| {
            let path = entry.path();
            let file_name = path.file_name()?.to_string_lossy();
            let captures = re.captures(&file_name)?;
            parse_version(&captures["version"]).ok()
        })
        .collect();

    Ok(versions)
}
/// Reads the contents of a directory and returns the set of all versions found
/// in the directory's listing by matching filenames against the specified regex
/// and parsing the `version` named capture as a semantic version.
///
/// The regex should contain the `version` named capture by using the Rust regex
/// syntax `?P<version>`.
Reads the contents of a directory and returns the set of all versions found
in the directory's listing by matching filenames against the specified regex
and parsing the `version` named capture as a semantic version.

The regex should contain the `version` named capture by using the Rust regex
syntax `?P`.
Reads the contents of a directory and returns the set of all versions found in the directory ' s listing by matching filenames against the specified regex and parsing the ` version ` named capture as a semantic version . The regex should contain the ` version ` named capture by using the Rust regex syntax ` ?P ` .
fn versions_matching(dir: &Path, re: &Regex) -> Fallible<BTreeSet<Version>> {
    let contents = read_dir_eager(dir).with_context(|_| ErrorDetails::ReadDirError {
        dir: dir.to_path_buf(),
    })?;
    let versions = contents
        .filter(|(_, metadata)| metadata.is_file())
        .filter_map(|(entry, _)| {
            let path = entry.path();
            let file_name = path.file_name()?.to_string_lossy();
            let captures = re.captures(&file_name)?;
            parse_version(&captures["version"]).ok()
        })
        .collect();
    Ok(versions)
}
fn versions_matching ( dir : & Path , re : & Regex ) -> Fallible < BTreeSet < Version > > { let contents = read_dir_eager ( dir ) . with_context ( | _ | ErrorDetails :: ReadDirError { dir : dir . to_path_buf ( ) , } ) ? ; let versions = contents . filter ( | ( _ , metadata ) | metadata . is_file ( ) ) . filter_map ( | ( entry , _ ) | { let path = entry . path ( ) ; let file_name = path . file_name ( ) ? . to_string_lossy ( ) ; let captures = re . captures ( & file_name ) ? ; parse_version ( & captures [ " " ] ) . ok ( ) } ) . collect ( ) ; Ok ( versions ) }
Reads the contents of a directory and returns the set of all versions found
in the directory's listing by matching filenames against the specified regex
and parsing the `version` named capture as a semantic version.
Reads the contents of a directory and returns the set of all versions found in the directory ' s listing by matching filenames against the specified regex and parsing the ` version ` named capture as a semantic version .
dir
&Path
re
&Regex
dir
&Path
re
&Regex