fn list_version_dirs(dir: &Path) -> io::Result<Vec<(u32, u32, String)>> {
    lazy_static! {
        // NOTE: Assuming dir names are like 1.10, not 1.10.0
        static ref RE_SEM_VER: Regex = Regex::new(r".*/(\d+)\.(\d+)").unwrap();
    }

    let mut versions = Vec::new();

    if try!(fs::metadata(dir)).is_dir() {
        for entry in try!(fs::read_dir(dir)) {
            let entry = try!(entry);
            let metadata = try!(fs::metadata(entry.path()));
            if metadata.is_dir() {
                if let Some(path) = entry.path().to_str() {
                    if let Some(cap) = RE_SEM_VER.captures(path) {
                        let v1 = cap.at(1).unwrap().to_string();
                        let v2 = cap.at(2).unwrap().to_string();

                        // these `unwrap()` should not panic. we can trust regex `\d+`, can't we?
                        let ver =
                            (v1.parse().unwrap(), v2.parse().unwrap(), format!("{}.{}", v1, v2));
                        versions.push(ver);
                    }
                }
            }
        }
    }

    Ok(versions)
}
/// Returns vec of version tuples. e.g. vec![(1. 9, "1.9"), (1, 10, "1.10")]
Returns vec of version tuples.
Returns vec of version tuples .
fn list_version_dirs(dir: &Path) -> io::Result<Vec<(u32, u32, String)>> {
    lazy_static! {
        // NOTE: Assuming dir names are like 1.10, not 1.10.0
        static ref RE_SEM_VER: Regex = Regex::new(r".*/(\d+)\.(\d+)").unwrap();
    }
    let mut versions = Vec::new();
    if try!(fs::metadata(dir)).is_dir() {
        for entry in try!(fs::read_dir(dir)) {
            let entry = try!(entry);
            let metadata = try!(fs::metadata(entry.path()));
            if metadata.is_dir() {
                if let Some(path) = entry.path().to_str() {
                    if let Some(cap) = RE_SEM_VER.captures(path) {
                        let v1 = cap.at(1).unwrap().to_string();
                        let v2 = cap.at(2).unwrap().to_string();
                        // these `unwrap()` should not panic. we can trust regex `\d+`, can't we?
                        let ver =
                            (v1.parse().unwrap(), v2.parse().unwrap(), format!("{}.{}", v1, v2));
                        versions.push(ver);
                    }
                }
            }
        }
    }
    Ok(versions)
}
fn list_version_dirs ( dir : & Path ) -> io :: Result < Vec < ( u32 , u32 , String ) > > { lazy_static ! { // NOTE: Assuming dir names are like 1.10, not 1.10.0 static ref RE_SEM_VER Regex Regex new ( r".*/(\d+)\.(\d+)" ) unwrap ( ) } let mut versions = Vec :: new ( ) ; if try ! ( fs metadata ( dir ) ) . is_dir ( ) { for entry in try ! ( fs read_dir ( dir ) ) { let entry = try ! ( entry ) ; let metadata = try ! ( fs metadata ( entry path ( ) ) ) ; if metadata . is_dir ( ) { if let Some ( path ) = entry . path ( ) . to_str ( ) { if let Some ( cap ) = RE_SEM_VER . captures ( path ) { let v1 = cap . at ( 1 ) . unwrap ( ) . to_string ( ) ; let v2 = cap . at ( 2 ) . unwrap ( ) . to_string ( ) ; // these `unwrap()` should not panic. we can trust regex `\d+`, can't we? let ver = ( v1 . parse ( ) . unwrap ( ) , v2 . parse ( ) . unwrap ( ) , format ! ( " " v1 v2 ) ) ; versions . push ( ver ) ; } } } } } Ok ( versions ) }
Returns vec of version tuples.
Returns vec of version tuples .
dir
&Path
dir
&Path