Remove lifetimes from wasm ast nodes.
This commit is contained in:
@@ -5,7 +5,6 @@ use serde::Serialize;
|
||||
use super::additional_property::AdditionalProperties;
|
||||
use super::additional_property::AdditionalPropertyValue;
|
||||
use super::ast_node::WasmAstNode;
|
||||
use super::ast_node::WasmAstWrapper;
|
||||
use super::macros::to_wasm;
|
||||
use super::standard_properties::WasmStandardProperties;
|
||||
use super::to_wasm::ToWasm;
|
||||
@@ -15,22 +14,22 @@ use crate::types::Document;
|
||||
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(tag = "ast_node")]
|
||||
#[serde(tag = "__ast_node")]
|
||||
#[serde(rename = "org-data")]
|
||||
pub struct WasmDocument<'s, 'p> {
|
||||
pub struct WasmDocument {
|
||||
#[serde(rename = "standard-properties")]
|
||||
pub(crate) standard_properties: WasmStandardProperties,
|
||||
#[serde(flatten)]
|
||||
pub(crate) additional_properties: AdditionalProperties<'s, 'p>,
|
||||
pub(crate) additional_properties: AdditionalProperties,
|
||||
#[serde(rename = "__children")]
|
||||
pub(crate) children: Vec<WasmAstNode<'s, 'p>>,
|
||||
pub(crate) children: Vec<WasmAstNode>,
|
||||
#[serde(rename = "CATEGORY")]
|
||||
pub(crate) category: Option<&'p str>,
|
||||
pub(crate) category: Option<String>,
|
||||
pub(crate) path: Option<PathBuf>,
|
||||
}
|
||||
|
||||
to_wasm!(
|
||||
WasmDocument<'s, 'p>,
|
||||
WasmDocument,
|
||||
Document<'s>,
|
||||
original,
|
||||
wasm_context,
|
||||
@@ -43,7 +42,7 @@ to_wasm!(
|
||||
for (name, val) in original.get_additional_properties().map(|node_property| {
|
||||
(
|
||||
node_property.property_name.to_uppercase(),
|
||||
AdditionalPropertyValue::SingleString(node_property.value.unwrap_or("")),
|
||||
AdditionalPropertyValue::SingleString(node_property.value.unwrap_or("").to_owned()),
|
||||
)
|
||||
}) {
|
||||
additional_properties.properties.insert(name, val);
|
||||
@@ -55,12 +54,12 @@ to_wasm!(
|
||||
.map(|child| {
|
||||
child
|
||||
.to_wasm(wasm_context.clone())
|
||||
.map(Into::<WasmAstNode<'_, '_>>::into)
|
||||
.map(Into::<WasmAstNode>::into)
|
||||
})
|
||||
.chain(original.children.iter().map(|child| {
|
||||
child
|
||||
.to_wasm(wasm_context.clone())
|
||||
.map(Into::<WasmAstNode<'_, '_>>::into)
|
||||
.map(Into::<WasmAstNode>::into)
|
||||
}))
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
|
||||
@@ -68,34 +67,21 @@ to_wasm!(
|
||||
standard_properties,
|
||||
additional_properties,
|
||||
children,
|
||||
category,
|
||||
category: category.map(str::to_owned),
|
||||
path,
|
||||
})
|
||||
}
|
||||
);
|
||||
|
||||
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmDocument<'s, 'p> {
|
||||
fn into(self) -> WasmAstNode<'s, 'p> {
|
||||
impl Into<WasmAstNode> for WasmDocument {
|
||||
fn into(self) -> WasmAstNode {
|
||||
WasmAstNode::Document(self)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "wasm_test")]
|
||||
impl<'s, 'p> ElispFact<'s> for WasmDocument<'s, 'p> {
|
||||
impl<'s> ElispFact<'s> for WasmDocument {
|
||||
fn get_elisp_name<'b>(&'b self) -> std::borrow::Cow<'s, str> {
|
||||
"org-data".into()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'b, 's, 'p> Into<WasmAstWrapper<'b, 's, 'p, &'b WasmDocument<'s, 'p>>>
|
||||
for &'b WasmDocument<'s, 'p>
|
||||
{
|
||||
fn into(self) -> WasmAstWrapper<'b, 's, 'p, &'b WasmDocument<'s, 'p>> {
|
||||
WasmAstWrapper::new(
|
||||
self.get_elisp_name(),
|
||||
&self.standard_properties,
|
||||
self,
|
||||
&self.children,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user