xref: /third_party/rust/crates/syn/codegen/src/json.rs
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/rust/crates/syn/codegen/src/
1fad3a1d3Sopenharmony_ciuse crate::workspace_path;
2fad3a1d3Sopenharmony_ciuse anyhow::Result;
3fad3a1d3Sopenharmony_ciuse std::fs;
4fad3a1d3Sopenharmony_ciuse syn_codegen::Definitions;
5fad3a1d3Sopenharmony_ci
6fad3a1d3Sopenharmony_cipub fn generate(defs: &Definitions) -> Result<()> {
7fad3a1d3Sopenharmony_ci    let mut j = serde_json::to_string_pretty(&defs)?;
8fad3a1d3Sopenharmony_ci    j.push('\n');
9fad3a1d3Sopenharmony_ci
10fad3a1d3Sopenharmony_ci    let check: Definitions = serde_json::from_str(&j)?;
11fad3a1d3Sopenharmony_ci    assert_eq!(*defs, check);
12fad3a1d3Sopenharmony_ci
13fad3a1d3Sopenharmony_ci    let json_path = workspace_path::get("syn.json");
14fad3a1d3Sopenharmony_ci    fs::write(json_path, j)?;
15fad3a1d3Sopenharmony_ci
16fad3a1d3Sopenharmony_ci    Ok(())
17fad3a1d3Sopenharmony_ci}
18

Indexes created Thu Nov 07 10:32:03 CST 2024