Elide __construct_component function

legacy
Charlotte Som 2021-09-12 21:45:13 +01:00
parent aff1f8b59e
commit 323d30b7d6
1 changed files with 7 additions and 16 deletions

View File

@ -39,23 +39,14 @@ pub fn convert_matrix(message: &str) -> MessageContent {
components.push(MessageComponent::Plain(text.borrow().clone()));
}
NodeData::Element(element) => {
fn __construct_component(
component_type: fn(MessageContent) -> MessageComponent,
components: MessageContent,
parents: &mut Vec<MessageContent>,
) -> MessageContent {
if let Some(mut parent_components) = parents.pop() {
parent_components.push((component_type)(components));
parent_components
} else {
vec![]
}
}
macro_rules! construct_component {
($f:expr) => {
components = __construct_component($f, components, &mut parents);
};
($f:expr) => {{
let component_type = $f;
if let Some(mut parent_components) = parents.pop() {
parent_components.push((component_type)(components));
components = parent_components;
}
}};
}
if element.name.ns == ns!(html) {