1 use crate::workspace_path; 2 use anyhow::Result; 3 use std::fs; 4 use syn_codegen::Definitions; 5 generate(defs: &Definitions) -> Result<()>6pub fn generate(defs: &Definitions) -> Result<()> { 7 let mut j = serde_json::to_string_pretty(&defs)?; 8 j.push('\n'); 9 10 let check: Definitions = serde_json::from_str(&j)?; 11 assert_eq!(*defs, check); 12 13 let json_path = workspace_path::get("syn.json"); 14 fs::write(json_path, j)?; 15 16 Ok(()) 17 } 18