pub fn expand_into_categories(
    unexpanded: Vec<UnicodeData>,
    propvals: &PropertyValues,
) -> Result<BTreeMap<String, BTreeSet<u32>>> {
    // Expand all of our UnicodeData rows. This results in one big list of
    // all assigned codepoints.
    let rows: Vec<_> = UnicodeDataExpander::new(unexpanded).collect();

    // Collect each general category into an ordered set.
    let mut bycat: BTreeMap<String, BTreeSet<u32>> = BTreeMap::new();
    let mut assigned = BTreeSet::new();
    for row in rows {
        assigned.insert(row.codepoint.value());
        let gc = propvals.canonical("gc", &row.general_category)?.to_string();
        bycat
            .entry(gc)
            .or_insert(BTreeSet::new())
            .insert(row.codepoint.value());
    }
    // As a special case, collect all unassigned codepoints.
    let unassigned_name = propvals.canonical("gc", "unassigned")?.to_string();
    bycat.insert(unassigned_name.clone(), BTreeSet::new());
    for cp in 0..=0x10FFFF {
        if !assigned.contains(&cp) {
            bycat.get_mut(&unassigned_name).unwrap().insert(cp);
        }
    }

    Ok(bycat)
}
/// Expand a list of UnicodeData rows and group by category.
Expand a list of UnicodeData rows and group by category.
Expand a list of UnicodeData rows and group by category .
pub fn expand_into_categories(
    unexpanded: Vec<UnicodeData>,
    propvals: &PropertyValues,
) -> Result<BTreeMap<String, BTreeSet<u32>>> {
    // Expand all of our UnicodeData rows. This results in one big list of
    // all assigned codepoints.
    let rows: Vec<_> = UnicodeDataExpander::new(unexpanded).collect();
    // Collect each general category into an ordered set.
    let mut bycat: BTreeMap<String, BTreeSet<u32>> = BTreeMap::new();
    let mut assigned = BTreeSet::new();
    for row in rows {
        assigned.insert(row.codepoint.value());
        let gc = propvals.canonical("gc", &row.general_category)?.to_string();
        bycat
            .entry(gc)
            .or_insert(BTreeSet::new())
            .insert(row.codepoint.value());
    }
    // As a special case, collect all unassigned codepoints.
    let unassigned_name = propvals.canonical("gc", "unassigned")?.to_string();
    bycat.insert(unassigned_name.clone(), BTreeSet::new());
    for cp in 0..=0x10FFFF {
        if !assigned.contains(&cp) {
            bycat.get_mut(&unassigned_name).unwrap().insert(cp);
        }
    }
    Ok(bycat)
}
pub fn expand_into_categories ( unexpanded : Vec < UnicodeData > , propvals : & PropertyValues , ) -> Result < BTreeMap < String , BTreeSet < u32 > > > { // Expand all of our UnicodeData rows. This results in one big list of // all assigned codepoints. let rows : Vec < _ > = UnicodeDataExpander :: new ( unexpanded ) . collect ( ) ; // Collect each general category into an ordered set. let mut bycat : BTreeMap < String , BTreeSet < u32 > > = BTreeMap :: new ( ) ; let mut assigned = BTreeSet :: new ( ) ; for row in rows { assigned . insert ( row . codepoint . value ( ) ) ; let gc = propvals . canonical ( " " , & row . general_category ) ? . to_string ( ) ; bycat . entry ( gc ) . or_insert ( BTreeSet :: new ( ) ) . insert ( row . codepoint . value ( ) ) ; } // As a special case, collect all unassigned codepoints. let unassigned_name = propvals . canonical ( " " , " " ) ? . to_string ( ) ; bycat . insert ( unassigned_name . clone ( ) , BTreeSet :: new ( ) ) ; for cp in 0 ..= 0x10FFFF { if ! assigned . contains ( & cp ) { bycat . get_mut ( & unassigned_name ) . unwrap ( ) . insert ( cp ) ; } } Ok ( bycat ) }
Expand a list of UnicodeData rows and group by category.
Expand a list of UnicodeData rows and group by category .
unexpanded
Vec<UnicodeData>
propvals
&PropertyValues
unexpanded
Vec<UnicodeData>
propvals
&PropertyValues