fn from_nointro_region<S: AsRef<str> + ?Sized>(region_str: &S)-> Result<(Vec<&str>, Vec<Region>)> {
    let mut regions = IndexSet::<Region>::new();
    let mut region_strings = Vec::new();

    let mut region_count = 0;
    let mut region_string_index = 0;

    for region_code in region_str.as_ref().split(", ") {
        if !region_code.chars().all(|c| char::is_ascii_alphabetic(&c) || c == ' ') {
            return Err(RegionError::BadRegionCode(
                RegionFormat::NoIntro,
                region_count,
                region_string_index,
            ));
        }

        match region_code {
            "World" | "World (guessed)" | "World (Guessed)" => {
                regions.insert(Region::UnitedStates);
                regions.insert(Region::Japan);
                regions.insert(Region::Europe);
            }
            "Scandinavia" => {
                regions.insert(Region::Denmark);
                regions.insert(Region::Norway);
                regions.insert(Region::Sweden);
            }
            "Latin America" => {
                regions.insert(Region::Mexico);
                regions.insert(Region::Brazil);
                regions.insert(Region::Argentina);
                regions.insert(Region::Chile);
                regions.insert(Region::Peru);
            }
            _ => match NOINTRO_REGION.get(region_code) {
                Some(&region) => {
                    regions.insert(region);
                }
                None => return Err(
                    RegionError::BadRegionCode(RegionFormat::NoIntro,
                                               region_count, region_string_index)
                ),
            },
        }
        region_strings.push(region_code);
        // If there was error we would have deleted..
        region_count += 1;
        region_string_index += region_code.len();
        region_string_index += ", ".len();
    }

    // invariant: Do not return RegionError::BadRegionCode because region_string_index will
    // overflow.
    if regions.is_empty() {
        Err(RegionError::NoRegions(RegionFormat::NoIntro))
    } else {
        Ok((region_strings, regions.into_iter().collect::<Vec<Region>>()))
    }
}
/// Parse a valid No-Intro region string into a `Vec<Region>`.
/// A valid region string is a comma + space separated list of valid country names.
///
/// Country names are case sensitive.
///
/// The following strings are expanded
///
/// - `World` is expanded to USA, Japan, and Europe.
/// - `Scandinavia` is expanded to Denmark, Norway, and Sweden.
/// # Arguments
/// - `region_str` The region string.
Parse a valid No-Intro region string into a `Vec`.
A valid region string is a comma + space separated list of valid country names.

Country names are case sensitive.

The following strings are expanded

`World` is expanded to USA, Japan, and Europe.
`Scandinavia` is expanded to Denmark, Norway, and Sweden.
Parse a valid No - Intro region string into a ` Vec ` . A valid region string is a comma + space separated list of valid country names . Country names are case sensitive . The following strings are expanded ` World ` is expanded to USA Japan and Europe . ` Scandinavia ` is expanded to Denmark Norway and Sweden .
fn from_nointro_region<S: AsRef<str> + ?Sized>(region_str: &S)-> Result<(Vec<&str>, Vec<Region>)> {
    let mut regions = IndexSet::<Region>::new();
    let mut region_strings = Vec::new();
    let mut region_count = 0;
    let mut region_string_index = 0;
    for region_code in region_str.as_ref().split(", ") {
        if !region_code.chars().all(|c| char::is_ascii_alphabetic(&c) || c == ' ') {
            return Err(RegionError::BadRegionCode(
                RegionFormat::NoIntro,
                region_count,
                region_string_index,
            ));
        }
        match region_code {
            "World" | "World (guessed)" | "World (Guessed)" => {
                regions.insert(Region::UnitedStates);
                regions.insert(Region::Japan);
                regions.insert(Region::Europe);
            }
            "Scandinavia" => {
                regions.insert(Region::Denmark);
                regions.insert(Region::Norway);
                regions.insert(Region::Sweden);
            }
            "Latin America" => {
                regions.insert(Region::Mexico);
                regions.insert(Region::Brazil);
                regions.insert(Region::Argentina);
                regions.insert(Region::Chile);
                regions.insert(Region::Peru);
            }
            _ => match NOINTRO_REGION.get(region_code) {
                Some(&region) => {
                    regions.insert(region);
                }
                None => return Err(
                    RegionError::BadRegionCode(RegionFormat::NoIntro,
                                               region_count, region_string_index)
                ),
            },
        }
        region_strings.push(region_code);
        // If there was error we would have deleted..
        region_count += 1;
        region_string_index += region_code.len();
        region_string_index += ", ".len();
    }
    // invariant: Do not return RegionError::BadRegionCode because region_string_index will
    // overflow.
    if regions.is_empty() {
        Err(RegionError::NoRegions(RegionFormat::NoIntro))
    } else {
        Ok((region_strings, regions.into_iter().collect::<Vec<Region>>()))
    }
}
fn from_nointro_region < S : AsRef < str > + ? Sized > ( region_str : & S ) -> Result < ( Vec < & str > , Vec < Region > ) > { let mut regions = IndexSet :: < Region > :: new ( ) ; let mut region_strings = Vec :: new ( ) ; let mut region_count = 0 ; let mut region_string_index = 0 ; for region_code in region_str . as_ref ( ) . split ( " " ) { if ! region_code . chars ( ) . all ( | c | char :: is_ascii_alphabetic ( & c ) || c == ' ' ) { return Err ( RegionError :: BadRegionCode ( RegionFormat :: NoIntro , region_count , region_string_index , ) ) ; } match region_code { " " | " " | " " => { regions . insert ( Region :: UnitedStates ) ; regions . insert ( Region :: Japan ) ; regions . insert ( Region :: Europe ) ; } " " => { regions . insert ( Region :: Denmark ) ; regions . insert ( Region :: Norway ) ; regions . insert ( Region :: Sweden ) ; } " " => { regions . insert ( Region :: Mexico ) ; regions . insert ( Region :: Brazil ) ; regions . insert ( Region :: Argentina ) ; regions . insert ( Region :: Chile ) ; regions . insert ( Region :: Peru ) ; } _ => match NOINTRO_REGION . get ( region_code ) { Some ( & region ) => { regions . insert ( region ) ; } None => return Err ( RegionError :: BadRegionCode ( RegionFormat :: NoIntro , region_count , region_string_index ) ) , } , } region_strings . push ( region_code ) ; // If there was error we would have deleted.. region_count += 1 ; region_string_index += region_code . len ( ) ; region_string_index += " " . len ( ) ; } // invariant: Do not return RegionError::BadRegionCode because region_string_index will // overflow. if regions . is_empty ( ) { Err ( RegionError :: NoRegions ( RegionFormat :: NoIntro ) ) } else { Ok ( ( region_strings , regions . into_iter ( ) . collect :: < Vec < Region > > ( ) ) ) } }
Parse a valid No-Intro region string into a `Vec<Region>`.
Parse a valid No - Intro region string into a ` Vec<Region > ` .
region_str
&S
The region string.
The region string .