pub fn codepoint_to_codepoints(
        &mut self,
        name: &str,
        map: &BTreeMap<u32, Vec<u32>>,
    ) -> Result<()> {
        if self.opts.fst_dir.is_some() {
            return err!("cannot emit codepoint->codepoints map as an FST");
        }

        self.header()?;
        self.separator()?;

        let name = rust_const_name(name);
        let ty = self.rust_codepoint_type();
        writeln!(
            self.wtr,
            "pub const {}: &'static [({}, &'static [{}])] = &[",
            name, ty, ty
        )?;
        'LOOP: for (&k, vs) in map {
            // Make sure both our keys and values can be represented in the
            // user's chosen codepoint format.
            let kstr = match self.rust_codepoint(k) {
                None => continue 'LOOP,
                Some(k) => k,
            };
            let mut vstrs = vec![];
            for &v in vs {
                match self.rust_codepoint(v) {
                    None => continue 'LOOP,
                    Some(v) => vstrs.push(v),
                }
            }

            self.wtr.write_str(&format!("({}, &[", kstr))?;
            if vstrs.len() == 1 {
                self.wtr.write_str(&format!("{}", &vstrs[0]))?;
            } else {
                for v in vstrs {
                    self.wtr.write_str(&format!("{}, ", v))?;
                }
            }
            self.wtr.write_str("]), ")?;
        }
        writeln!(self.wtr, "];")?;

        self.wtr.flush()?;
        Ok(())
    }
/// Write a map that associates codepoints with a sequence of other
/// codepoints.
///
/// This does not support the FST format.
Write a map that associates codepoints with a sequence of other
codepoints.

This does not support the FST format.
Write a map that associates codepoints with a sequence of other codepoints . This does not support the FST format .
pub fn codepoint_to_codepoints(
        &mut self,
        name: &str,
        map: &BTreeMap<u32, Vec<u32>>,
    ) -> Result<()> {
        if self.opts.fst_dir.is_some() {
            return err!("cannot emit codepoint->codepoints map as an FST");
        }
        self.header()?;
        self.separator()?;
        let name = rust_const_name(name);
        let ty = self.rust_codepoint_type();
        writeln!(
            self.wtr,
            "pub const {}: &'static [({}, &'static [{}])] = &[",
            name, ty, ty
        )?;
        'LOOP: for (&k, vs) in map {
            // Make sure both our keys and values can be represented in the
            // user's chosen codepoint format.
            let kstr = match self.rust_codepoint(k) {
                None => continue 'LOOP,
                Some(k) => k,
            };
            let mut vstrs = vec![];
            for &v in vs {
                match self.rust_codepoint(v) {
                    None => continue 'LOOP,
                    Some(v) => vstrs.push(v),
                }
            }
            self.wtr.write_str(&format!("({}, &[", kstr))?;
            if vstrs.len() == 1 {
                self.wtr.write_str(&format!("{}", &vstrs[0]))?;
            } else {
                for v in vstrs {
                    self.wtr.write_str(&format!("{}, ", v))?;
                }
            }
            self.wtr.write_str("]), ")?;
        }
        writeln!(self.wtr, "];")?;
        self.wtr.flush()?;
        Ok(())
    }
pub fn codepoint_to_codepoints ( & mut self , name : & str , map : & BTreeMap < u32 , Vec < u32 > > , ) -> Result < ( ) > { if self . opts . fst_dir . is_some ( ) { return err ! ( " " ) ; } self . header ( ) ? ; self . separator ( ) ? ; let name = rust_const_name ( name ) ; let ty = self . rust_codepoint_type ( ) ; writeln ! ( self wtr " " name ty ty ) ? ; ' LOOP : for ( & k , vs ) in map { // Make sure both our keys and values can be represented in the // user's chosen codepoint format. let kstr = match self . rust_codepoint ( k ) { None => continue ' LOOP , Some ( k ) => k , } ; let mut vstrs = vec ! [ ] ; for & v in vs { match self . rust_codepoint ( v ) { None => continue ' LOOP , Some ( v ) => vstrs . push ( v ) , } } self . wtr . write_str ( & format ! ( " " kstr ) ) ? ; if vstrs . len ( ) == 1 { self . wtr . write_str ( & format ! ( " " vstrs [ 0 ] ) ) ? ; } else { for v in vstrs { self . wtr . write_str ( & format ! ( " " v ) ) ? ; } } self . wtr . write_str ( " " ) ? ; } writeln ! ( self wtr " " ) ? ; self . wtr . flush ( ) ? ; Ok ( ( ) ) }
Write a map that associates codepoints with a sequence of other
codepoints.
Write a map that associates codepoints with a sequence of other codepoints .
&mut self
name
&str
map
&BTreeMap<u32, Vec<u32>>
&mut self
name
&str
map
&BTreeMap<u32, Vec<u32>>