fn from_string(ver: &String) -> Result<Self, String> {
        let mut char_iter = ver.chars();
        let mut major_ver: Vec<char> = Vec::new();
        let mut dot = false;
        for c in char_iter.by_ref() {
            if c == '.' {
                dot = true;
                break;
            } else if c.is_ascii_digit() {
                major_ver.push(c);
            } else {
                return Err(format!(
                    "{:?} contains a non-numeric and non-period character",
                    ver
                ));
            }
        }

        let mut minor_ver: Vec<char> = Vec::new();
        if dot {
            for c in char_iter.by_ref() {
                if c.is_ascii_digit() {
                    minor_ver.push(c);
                } else {
                    return Err(format!(
                        "{:?} contains a non-numeric character after a period",
                        ver
                    ));
                }
            }
        }

        if major_ver.len() == 0 {
            Err(format!("version string is empty"))
        } else {
            let major = char_vec_to_int(&major_ver)?;
            if !dot {
                Ok(RequestedVersion::Loose(major))
            } else if minor_ver.len() == 0 {
                Err(format!("{:?} is missing a minor version number", ver))
            } else {
                let minor = char_vec_to_int(&minor_ver)?;
                Ok(RequestedVersion::Exact(major, minor))
            }
        }
    }
/// Creates a new `RequestedVersion` from a version specifier string.
Creates a new `RequestedVersion` from a version specifier string.
Creates a new ` RequestedVersion ` from a version specifier string .
fn from_string(ver: &String) -> Result<Self, String> {
        let mut char_iter = ver.chars();
        let mut major_ver: Vec<char> = Vec::new();
        let mut dot = false;
        for c in char_iter.by_ref() {
            if c == '.' {
                dot = true;
                break;
            } else if c.is_ascii_digit() {
                major_ver.push(c);
            } else {
                return Err(format!(
                    "{:?} contains a non-numeric and non-period character",
                    ver
                ));
            }
        }
        let mut minor_ver: Vec<char> = Vec::new();
        if dot {
            for c in char_iter.by_ref() {
                if c.is_ascii_digit() {
                    minor_ver.push(c);
                } else {
                    return Err(format!(
                        "{:?} contains a non-numeric character after a period",
                        ver
                    ));
                }
            }
        }
        if major_ver.len() == 0 {
            Err(format!("version string is empty"))
        } else {
            let major = char_vec_to_int(&major_ver)?;
            if !dot {
                Ok(RequestedVersion::Loose(major))
            } else if minor_ver.len() == 0 {
                Err(format!("{:?} is missing a minor version number", ver))
            } else {
                let minor = char_vec_to_int(&minor_ver)?;
                Ok(RequestedVersion::Exact(major, minor))
            }
        }
    }
fn from_string ( ver : & String ) -> Result < Self , String > { let mut char_iter = ver . chars ( ) ; let mut major_ver : Vec < char > = Vec :: new ( ) ; let mut dot = false ; for c in char_iter . by_ref ( ) { if c == '.' { dot = true ; break ; } else if c . is_ascii_digit ( ) { major_ver . push ( c ) ; } else { return Err ( format ! ( " " ver ) ) ; } } let mut minor_ver : Vec < char > = Vec :: new ( ) ; if dot { for c in char_iter . by_ref ( ) { if c . is_ascii_digit ( ) { minor_ver . push ( c ) ; } else { return Err ( format ! ( " " ver ) ) ; } } } if major_ver . len ( ) == 0 { Err ( format ! ( " " ) ) } else { let major = char_vec_to_int ( & major_ver ) ? ; if ! dot { Ok ( RequestedVersion :: Loose ( major ) ) } else if minor_ver . len ( ) == 0 { Err ( format ! ( " " ver ) ) } else { let minor = char_vec_to_int ( & minor_ver ) ? ; Ok ( RequestedVersion :: Exact ( major , minor ) ) } } }
Creates a new `RequestedVersion` from a version specifier string.
Creates a new ` RequestedVersion ` from a version specifier string .
ver
&String
ver
&String