fn from_str(version_number_str: &'p str) -> Self {
        fn split_and_parse_number(version_part: &str) -> (u8, Option<&str>) {
            match version_part.find(|c: char| !c.is_ascii_digit()) {
                None => (version_part.parse().unwrap(), None),
                Some(version_part_suffix_start) => {
                    let (version_part, version_part_suffix) =
                        version_part.split_at(version_part_suffix_start);
                    (version_part.parse().unwrap(), Some(version_part_suffix))
                }
            }
        }

        let mut parts = version_number_str.split('.');
        let major_str = parts.next().expect("Python major version missing");
        let minor_str = parts.next().expect("Python minor version missing");
        let patch_str = parts.next();
        assert!(
            parts.next().is_none(),
            "Python version string has too many parts"
        );

        let major = major_str
            .parse()
            .expect("Python major version not an integer");
        let (minor, suffix) = split_and_parse_number(minor_str);
        if suffix.is_some() {
            assert!(patch_str.is_none());
            return PythonVersionInfo {
                major,
                minor,
                patch: 0,
                suffix,
            };
        }

        let (patch, suffix) = patch_str.map(split_and_parse_number).unwrap_or_default();
        PythonVersionInfo {
            major,
            minor,
            patch,
            suffix,
        }
    }
/// Parses a hard-coded Python interpreter version string (e.g. 3.9.0a4+).
///
/// Panics if the string is ill-formatted.
Parses a hard-coded Python interpreter version string .
Panics if the string is ill-formatted.
Parses a hard - coded Python interpreter version string . Panics if the string is ill - formatted .
fn from_str(version_number_str: &'p str) -> Self {
        fn split_and_parse_number(version_part: &str) -> (u8, Option<&str>) {
            match version_part.find(|c: char| !c.is_ascii_digit()) {
                None => (version_part.parse().unwrap(), None),
                Some(version_part_suffix_start) => {
                    let (version_part, version_part_suffix) =
                        version_part.split_at(version_part_suffix_start);
                    (version_part.parse().unwrap(), Some(version_part_suffix))
                }
            }
        }
        let mut parts = version_number_str.split('.');
        let major_str = parts.next().expect("Python major version missing");
        let minor_str = parts.next().expect("Python minor version missing");
        let patch_str = parts.next();
        assert!(
            parts.next().is_none(),
            "Python version string has too many parts"
        );
        let major = major_str
            .parse()
            .expect("Python major version not an integer");
        let (minor, suffix) = split_and_parse_number(minor_str);
        if suffix.is_some() {
            assert!(patch_str.is_none());
            return PythonVersionInfo {
                major,
                minor,
                patch: 0,
                suffix,
            };
        }
        let (patch, suffix) = patch_str.map(split_and_parse_number).unwrap_or_default();
        PythonVersionInfo {
            major,
            minor,
            patch,
            suffix,
        }
    }
fn from_str ( version_number_str : & ' p str ) -> Self { fn split_and_parse_number ( version_part : & str ) -> ( u8 , Option < & str > ) { match version_part . find ( | c : char | ! c . is_ascii_digit ( ) ) { None => ( version_part . parse ( ) . unwrap ( ) , None ) , Some ( version_part_suffix_start ) => { let ( version_part , version_part_suffix ) = version_part . split_at ( version_part_suffix_start ) ; ( version_part . parse ( ) . unwrap ( ) , Some ( version_part_suffix ) ) } } } let mut parts = version_number_str . split ( '.' ) ; let major_str = parts . next ( ) . expect ( " " ) ; let minor_str = parts . next ( ) . expect ( " " ) ; let patch_str = parts . next ( ) ; assert ! ( parts next ( ) is_none ( ) " " ) ; let major = major_str . parse ( ) . expect ( " " ) ; let ( minor , suffix ) = split_and_parse_number ( minor_str ) ; if suffix . is_some ( ) { assert ! ( patch_str is_none ( ) ) ; return PythonVersionInfo { major , minor , patch : 0 , suffix , } ; } let ( patch , suffix ) = patch_str . map ( split_and_parse_number ) . unwrap_or_default ( ) ; PythonVersionInfo { major , minor , patch , suffix , } }
Parses a hard-coded Python interpreter version string (e.g.
Parses a hard - coded Python interpreter version string ( e . g .
version_number_str
&'p str