• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 use anyhow::Result;
2 use std::fs;
3 use std::path::Path;
4 use syn_codegen::Definitions;
5 
generate(defs: &Definitions) -> Result<()>6 pub 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 codegen_root = Path::new(env!("CARGO_MANIFEST_DIR"));
14     let json_path = codegen_root.join("../syn.json");
15     fs::write(json_path, j)?;
16 
17     Ok(())
18 }
19