pub fn write_glyph_set(
    output_path: &PathBuf,
    set: &GlyphSet,
) -> Result<(), Box<dyn std::error::Error>> {
    use std::fs::File;
    use std::io::Write;

    // https://doc.rust-lang.org/std/path/struct.Path.html#method.ends_with
    // Yikes, that's a footgun.

    let extension = output_path.extension().expect("should have an extension");
    let s;
    if extension == "json" {
        s = serde_json::to_string(&set)?;
    } else if extension == "yaml" {
        // Instead of relying on serde_yaml, we manually conver the glyph set here to ensure
        // newlines are convenient.
        s = to_yaml_string(&set);
    } else {
        return Err(Box::new(std::io::Error::new(
            std::io::ErrorKind::Other,
            format!("Unknown type: {:?}", output_path),
        )));
    }
    let mut file = File::create(output_path)?;
    file.write(s.as_bytes())?;

    Ok(())
}
/// Write a glyph set to a json or yaml file.
Write a glyph set to a json or yaml file.
Write a glyph set to a json or yaml file .
pub fn write_glyph_set(
    output_path: &PathBuf,
    set: &GlyphSet,
) -> Result<(), Box<dyn std::error::Error>> {
    use std::fs::File;
    use std::io::Write;
    // https://doc.rust-lang.org/std/path/struct.Path.html#method.ends_with
    // Yikes, that's a footgun.
    let extension = output_path.extension().expect("should have an extension");
    let s;
    if extension == "json" {
        s = serde_json::to_string(&set)?;
    } else if extension == "yaml" {
        // Instead of relying on serde_yaml, we manually conver the glyph set here to ensure
        // newlines are convenient.
        s = to_yaml_string(&set);
    } else {
        return Err(Box::new(std::io::Error::new(
            std::io::ErrorKind::Other,
            format!("Unknown type: {:?}", output_path),
        )));
    }
    let mut file = File::create(output_path)?;
    file.write(s.as_bytes())?;
    Ok(())
}
pub fn write_glyph_set ( output_path : & PathBuf , set : & GlyphSet , ) -> Result < ( ) , Box < dyn std :: error :: Error > > { use std :: fs :: File ; use std :: io :: Write ; // https://doc.rust-lang.org/std/path/struct.Path.html#method.ends_with // Yikes, that's a footgun. let extension = output_path . extension ( ) . expect ( " " ) ; let s ; if extension == " " { s = serde_json :: to_string ( & set ) ? ; } else if extension == " " { // Instead of relying on serde_yaml, we manually conver the glyph set here to ensure // newlines are convenient. s = to_yaml_string ( & set ) ; } else { return Err ( Box :: new ( std :: io :: Error :: new ( std :: io :: ErrorKind :: Other , format ! ( " " output_path ) , ) ) ) ; } let mut file = File :: create ( output_path ) ? ; file . write ( s . as_bytes ( ) ) ? ; Ok ( ( ) ) }
Write a glyph set to a json or yaml file.
Write a glyph set to a json or yaml file .
output_path
&PathBuf
set
&GlyphSet