Remove lifetimes from wasm ast nodes.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
use std::borrow::Cow;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use serde::Serialize;
|
||||
@@ -10,30 +11,27 @@ use crate::types::AffiliatedKeywords;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum AdditionalPropertyValue<'s, 'p> {
|
||||
SingleString(&'s str),
|
||||
ListOfStrings(Vec<&'s str>),
|
||||
OptionalPair {
|
||||
optval: Option<&'s str>,
|
||||
val: &'s str,
|
||||
},
|
||||
ObjectTree(Vec<(Option<Vec<WasmAstNode<'s, 'p>>>, Vec<WasmAstNode<'s, 'p>>)>),
|
||||
pub enum AdditionalPropertyValue {
|
||||
SingleString(String),
|
||||
ListOfStrings(Vec<String>),
|
||||
OptionalPair { optval: Option<String>, val: String },
|
||||
ObjectTree(Vec<(Option<Vec<WasmAstNode>>, Vec<WasmAstNode>)>),
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Default)]
|
||||
pub struct AdditionalProperties<'s, 'p> {
|
||||
pub struct AdditionalProperties {
|
||||
#[serde(flatten)]
|
||||
pub(crate) properties: HashMap<String, AdditionalPropertyValue<'s, 'p>>,
|
||||
pub(crate) properties: HashMap<String, AdditionalPropertyValue>,
|
||||
}
|
||||
|
||||
impl<'s, 'p> AdditionalProperties<'s, 'p> {
|
||||
impl AdditionalProperties {
|
||||
pub(crate) fn get_elisp_names<'c>(&'c self) -> impl Iterator<Item = String> + 'c {
|
||||
self.properties.keys().map(move |key| format!(":{}", key))
|
||||
}
|
||||
}
|
||||
|
||||
to_wasm!(
|
||||
AdditionalProperties<'s, 'p>,
|
||||
AdditionalProperties,
|
||||
AffiliatedKeywords<'s>,
|
||||
original,
|
||||
wasm_context,
|
||||
@@ -42,15 +40,17 @@ to_wasm!(
|
||||
for (name, val) in original.keywords.iter() {
|
||||
let converted_val = match val {
|
||||
AffiliatedKeywordValue::SingleString(val) => {
|
||||
AdditionalPropertyValue::SingleString(val)
|
||||
AdditionalPropertyValue::SingleString((*val).to_owned())
|
||||
}
|
||||
AffiliatedKeywordValue::ListOfStrings(val) => {
|
||||
AdditionalPropertyValue::ListOfStrings(val.clone())
|
||||
AdditionalPropertyValue::ListOfStrings(
|
||||
val.iter().map(|s| (*s).to_owned()).collect(),
|
||||
)
|
||||
}
|
||||
AffiliatedKeywordValue::OptionalPair { optval, val } => {
|
||||
AdditionalPropertyValue::OptionalPair {
|
||||
optval: optval.clone(),
|
||||
val: val,
|
||||
optval: optval.map(|s| (*s).to_owned()),
|
||||
val: (*val).to_owned(),
|
||||
}
|
||||
}
|
||||
AffiliatedKeywordValue::ObjectTree(val) => {
|
||||
@@ -64,7 +64,7 @@ to_wasm!(
|
||||
.map(|child| {
|
||||
child
|
||||
.to_wasm(wasm_context.clone())
|
||||
.map(Into::<WasmAstNode<'_, '_>>::into)
|
||||
.map(Into::<WasmAstNode>::into)
|
||||
})
|
||||
.collect::<Result<Vec<_>, _>>()?,
|
||||
)
|
||||
@@ -76,7 +76,7 @@ to_wasm!(
|
||||
.map(|child| {
|
||||
child
|
||||
.to_wasm(wasm_context.clone())
|
||||
.map(Into::<WasmAstNode<'_, '_>>::into)
|
||||
.map(Into::<WasmAstNode>::into)
|
||||
})
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user