fn split_version_str(
        version: &'a str,
        manifest: Option<&'a VersionManifest>,
    ) -> Option<Vec<VersionPart<'a>>> {
        // Split the version string, and create a vector to put the parts in
        // TODO: split at specific separators instead
        let split = version.split(|c| !char::is_alphanumeric(c));
        let mut parts = Vec::new();

        // Get the manifest to follow
        let mut used_manifest = &VersionManifest::new();
        if manifest.is_some() {
            used_manifest = manifest.unwrap();
        }

        // Flag to determine whether this version number contains any number part
        let mut has_number = false;

        // Loop over the parts, and parse them
        for part in split {
            // We may not go over the maximum depth
            if used_manifest.max_depth().is_some()
                && parts.len() >= used_manifest.max_depth_number()
            {
                break;
            }

            // Skip empty parts
            if part.is_empty() {
                continue;
            }

            // Try to parse the value as an number
            match part.parse::<i32>() {
                Ok(number) => {
                    // Push the number part to the vector, and set the has number flag
                    parts.push(VersionPart::Number(number));
                    has_number = true;
                }
                Err(_) => {
                    // Ignore text parts if specified
                    if used_manifest.ignore_text() {
                        continue;
                    }

                    // Push the text part to the vector
                    parts.push(VersionPart::Text(part))
                }
            }
        }

        // The version must contain a number part, if any part was parsed
        if !has_number && !parts.is_empty() {
            return None;
        }

        // Return the list of parts
        Some(parts)
    }
/// Split the given version string, in it's version parts.
/// TODO: Move this method to some sort of helper class, maybe as part of `VersionPart`.
Split the given version string, in it's version parts.
TODO: Move this method to some sort of helper class, maybe as part of `VersionPart`.
Split the given version string in it ' s version parts . TODO : Move this method to some sort of helper class maybe as part of ` VersionPart ` .
fn split_version_str(
        version: &'a str,
        manifest: Option<&'a VersionManifest>,
    ) -> Option<Vec<VersionPart<'a>>> {
        // Split the version string, and create a vector to put the parts in
        // TODO: split at specific separators instead
        let split = version.split(|c| !char::is_alphanumeric(c));
        let mut parts = Vec::new();
        // Get the manifest to follow
        let mut used_manifest = &VersionManifest::new();
        if manifest.is_some() {
            used_manifest = manifest.unwrap();
        }
        // Flag to determine whether this version number contains any number part
        let mut has_number = false;
        // Loop over the parts, and parse them
        for part in split {
            // We may not go over the maximum depth
            if used_manifest.max_depth().is_some()
                && parts.len() >= used_manifest.max_depth_number()
            {
                break;
            }
            // Skip empty parts
            if part.is_empty() {
                continue;
            }
            // Try to parse the value as an number
            match part.parse::<i32>() {
                Ok(number) => {
                    // Push the number part to the vector, and set the has number flag
                    parts.push(VersionPart::Number(number));
                    has_number = true;
                }
                Err(_) => {
                    // Ignore text parts if specified
                    if used_manifest.ignore_text() {
                        continue;
                    }
                    // Push the text part to the vector
                    parts.push(VersionPart::Text(part))
                }
            }
        }
        // The version must contain a number part, if any part was parsed
        if !has_number && !parts.is_empty() {
            return None;
        }
        // Return the list of parts
        Some(parts)
    }
fn split_version_str ( version : & ' a str , manifest : Option < & ' a VersionManifest > , ) -> Option < Vec < VersionPart < ' a > > > { // Split the version string, and create a vector to put the parts in // TODO: split at specific separators instead let split = version . split ( | c | ! char :: is_alphanumeric ( c ) ) ; let mut parts = Vec :: new ( ) ; // Get the manifest to follow let mut used_manifest = & VersionManifest :: new ( ) ; if manifest . is_some ( ) { used_manifest = manifest . unwrap ( ) ; } // Flag to determine whether this version number contains any number part let mut has_number = false ; // Loop over the parts, and parse them for part in split { // We may not go over the maximum depth if used_manifest . max_depth ( ) . is_some ( ) && parts . len ( ) >= used_manifest . max_depth_number ( ) { break ; } // Skip empty parts if part . is_empty ( ) { continue ; } // Try to parse the value as an number match part . parse :: < i32 > ( ) { Ok ( number ) => { // Push the number part to the vector, and set the has number flag parts . push ( VersionPart :: Number ( number ) ) ; has_number = true ; } Err ( _ ) => { // Ignore text parts if specified if used_manifest . ignore_text ( ) { continue ; } // Push the text part to the vector parts . push ( VersionPart :: Text ( part ) ) } } } // The version must contain a number part, if any part was parsed if ! has_number && ! parts . is_empty ( ) { return None ; } // Return the list of parts Some ( parts ) }
Split the given version string, in it's version parts.
Split the given version string in it ' s version parts .
version
&'a str
manifest
Option<&'a VersionManifest>
version
&'a str
manifest
Option<&'a VersionManifest>