pub fn ranges_to_enum(
        &mut self,
        name: &str,
        enum_map: &BTreeMap<String, BTreeSet<u32>>,
    ) -> Result<()> {
        self.header()?;
        self.separator()?;

        writeln!(
            self.wtr,
            "pub const {}_ENUM: &'static [&'static str] = &[",
            rust_const_name(name)
        )?;
        for variant in enum_map.keys() {
            self.wtr.write_str(&format!("{:?}, ", variant))?;
        }
        writeln!(self.wtr, "];")?;

        let mut map = BTreeMap::new();
        for (i, (_, ref set)) in enum_map.iter().enumerate() {
            map.extend(set.iter().cloned().map(|cp| (cp, i as u64)));
        }
        self.ranges_to_unsigned_integer(name, &map)?;
        self.wtr.flush()?;
        Ok(())
    }
/// Write a map that associates codepoint ranges to a single value in an
/// enumeration. This usually emits two items: a map from codepoint range
/// to index and a map from index to one of the enum variants.
///
/// The given map should be a map from the enum variant value to the set
/// of codepoints that have that value.
Write a map that associates codepoint ranges to a single value in an
enumeration. This usually emits two items: a map from codepoint range
to index and a map from index to one of the enum variants.

The given map should be a map from the enum variant value to the set
of codepoints that have that value.
Write a map that associates codepoint ranges to a single value in an enumeration . This usually emits two items : a map from codepoint range to index and a map from index to one of the enum variants . The given map should be a map from the enum variant value to the set of codepoints that have that value .
pub fn ranges_to_enum(
        &mut self,
        name: &str,
        enum_map: &BTreeMap<String, BTreeSet<u32>>,
    ) -> Result<()> {
        self.header()?;
        self.separator()?;
        writeln!(
            self.wtr,
            "pub const {}_ENUM: &'static [&'static str] = &[",
            rust_const_name(name)
        )?;
        for variant in enum_map.keys() {
            self.wtr.write_str(&format!("{:?}, ", variant))?;
        }
        writeln!(self.wtr, "];")?;
        let mut map = BTreeMap::new();
        for (i, (_, ref set)) in enum_map.iter().enumerate() {
            map.extend(set.iter().cloned().map(|cp| (cp, i as u64)));
        }
        self.ranges_to_unsigned_integer(name, &map)?;
        self.wtr.flush()?;
        Ok(())
    }
pub fn ranges_to_enum ( & mut self , name : & str , enum_map : & BTreeMap < String , BTreeSet < u32 > > , ) -> Result < ( ) > { self . header ( ) ? ; self . separator ( ) ? ; writeln ! ( self wtr " " rust_const_name ( name ) ) ? ; for variant in enum_map . keys ( ) { self . wtr . write_str ( & format ! ( " " variant ) ) ? ; } writeln ! ( self wtr " " ) ? ; let mut map = BTreeMap :: new ( ) ; for ( i , ( _ , ref set ) ) in enum_map . iter ( ) . enumerate ( ) { map . extend ( set . iter ( ) . cloned ( ) . map ( | cp | ( cp , i as u64 ) ) ) ; } self . ranges_to_unsigned_integer ( name , & map ) ? ; self . wtr . flush ( ) ? ; Ok ( ( ) ) }
Write a map that associates codepoint ranges to a single value in an
enumeration.
Write a map that associates codepoint ranges to a single value in an enumeration .
&mut self
name
&str
enum_map
&BTreeMap<String, BTreeSet<u32>>
&mut self
name
&str
enum_map
&BTreeMap<String, BTreeSet<u32>>