Fix parsing of symbol table
This commit is contained in:
@@ -2,7 +2,7 @@ use std::collections::BTreeMap;
|
||||
|
||||
use eyre::{bail, Context};
|
||||
use serde::Serialize;
|
||||
use serde_json::Value;
|
||||
use serde_json::{Map, Value};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Output {
|
||||
@@ -17,6 +17,22 @@ impl Output {
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn write_append(&mut self, key: &'static str, v: &impl Serialize) -> eyre::Result<()> {
|
||||
let Value::Object(mut v) =
|
||||
serde_json::to_value(v).wrap_err("failed to serialize output")?
|
||||
else {
|
||||
bail!("tried to append non-object");
|
||||
};
|
||||
|
||||
let Value::Object(entry) = self.elements.entry(key).or_insert(Map::new().into()) else {
|
||||
bail!("tried to append to non-object");
|
||||
};
|
||||
|
||||
entry.append(&mut v);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for Output {
|
||||
|
||||
Reference in New Issue
Block a user