Elide __construct_component function
parent
aff1f8b59e
commit
323d30b7d6
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue