use serde::Deserialize; use serde::Serialize; use super::ast_node::WasmAstNode; use super::macros::to_wasm; use super::to_wasm::ToWasm; use crate::compare::ElispFact; use crate::types::Citation; use crate::wasm::to_wasm::ToWasmStandardProperties; #[derive(Debug, Serialize, Deserialize)] pub struct WasmCitation { pub(crate) style: Option, pub(crate) prefix: Option>, pub(crate) suffix: Option>, } to_wasm!( WasmCitation, Citation<'s>, original, wasm_context, { WasmAstNode::Citation(original) }, { "citation".into() }, { let children = original .children .iter() .map(|child| { child .to_wasm(wasm_context.clone()) .map(Into::::into) }) .collect::, _>>()?; let prefix = original .prefix .iter() .map(|child| { child .to_wasm(wasm_context.clone()) .map(Into::::into) }) .collect::, _>>()?; let suffix = original .suffix .iter() .map(|child| { child .to_wasm(wasm_context.clone()) .map(Into::::into) }) .collect::, _>>()?; Ok(( children, WasmCitation { style: original.style.map(|s| s.to_owned()), prefix: if prefix.is_empty() { None } else { Some(prefix) }, suffix: if suffix.is_empty() { None } else { Some(suffix) }, }, )) } );