fn from_goodtools_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(",") {
        match region_code {
            "1" => {
                regions.insert(Region::Japan);
                regions.insert(Region::SouthKorea);
            }
            "4" => {
                regions.insert(Region::UnitedStates);
                regions.insert(Region::Brazil);
            }
            "5" => {
                regions.insert(Region::Japan);
                regions.insert(Region::UnitedStates);
            }
            "W" | "JUE" => {
                regions.insert(Region::Japan);
                regions.insert(Region::UnitedStates);
                regions.insert(Region::Europe);
            }
            "UE" => {
                regions.insert(Region::UnitedStates);
                regions.insert(Region::Europe);
            }
            "JU" => {
                regions.insert(Region::Japan);
                regions.insert(Region::UnitedStates);
            }
            _ => match GOODTOOLS_REGION.get(region_code)
            {
                Some(&region) => {
                    regions.insert(region);
                }
                None => return Err(
                    RegionError::BadRegionCode(RegionFormat::GoodTools,
                                               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::GoodTools))
    } else {
        Ok((region_strings, regions.into_iter().collect::<Vec<Region>>()))
    }
}
/// Parse a valid GoodTools region string into a `Vec<Region>`.
///
/// # Arguments
/// - `region_str` The region string.
Parse a valid GoodTools region string into a `Vec`.
Parse a valid GoodTools region string into a ` Vec ` .
fn from_goodtools_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(",") {
        match region_code {
            "1" => {
                regions.insert(Region::Japan);
                regions.insert(Region::SouthKorea);
            }
            "4" => {
                regions.insert(Region::UnitedStates);
                regions.insert(Region::Brazil);
            }
            "5" => {
                regions.insert(Region::Japan);
                regions.insert(Region::UnitedStates);
            }
            "W" | "JUE" => {
                regions.insert(Region::Japan);
                regions.insert(Region::UnitedStates);
                regions.insert(Region::Europe);
            }
            "UE" => {
                regions.insert(Region::UnitedStates);
                regions.insert(Region::Europe);
            }
            "JU" => {
                regions.insert(Region::Japan);
                regions.insert(Region::UnitedStates);
            }
            _ => match GOODTOOLS_REGION.get(region_code)
            {
                Some(&region) => {
                    regions.insert(region);
                }
                None => return Err(
                    RegionError::BadRegionCode(RegionFormat::GoodTools,
                                               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::GoodTools))
    } else {
        Ok((region_strings, regions.into_iter().collect::<Vec<Region>>()))
    }
}
fn from_goodtools_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 ( " " ) { match region_code { " " => { regions . insert ( Region :: Japan ) ; regions . insert ( Region :: SouthKorea ) ; } " " => { regions . insert ( Region :: UnitedStates ) ; regions . insert ( Region :: Brazil ) ; } " " => { regions . insert ( Region :: Japan ) ; regions . insert ( Region :: UnitedStates ) ; } " " | " " => { regions . insert ( Region :: Japan ) ; regions . insert ( Region :: UnitedStates ) ; regions . insert ( Region :: Europe ) ; } " " => { regions . insert ( Region :: UnitedStates ) ; regions . insert ( Region :: Europe ) ; } " " => { regions . insert ( Region :: Japan ) ; regions . insert ( Region :: UnitedStates ) ; } _ => match GOODTOOLS_REGION . get ( region_code ) { Some ( & region ) => { regions . insert ( region ) ; } None => return Err ( RegionError :: BadRegionCode ( RegionFormat :: GoodTools , 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 :: GoodTools ) ) } else { Ok ( ( region_strings , regions . into_iter ( ) . collect :: < Vec < Region > > ( ) ) ) } }
Parse a valid GoodTools region string into a `Vec<Region>`.
Parse a valid GoodTools region string into a ` Vec<Region > ` .
region_str
&S
The region string.
The region string .