Skip to content

Instantly share code, notes, and snippets.

@Aatch
Forked from metajack/handle_element.rs
Last active December 16, 2015 06:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Aatch/5393550 to your computer and use it in GitHub Desktop.
Save Aatch/5393550 to your computer and use it in GitHub Desktop.
macro_rules! handle_element(
($tag:expr, $string:expr, $ctor:ident, [], $type_id:expr) => ( () );
($tag:expr, $string:expr, $ctor:ident, [ $($field:ident),* ], $type_id:expr, ) => (
if eq_slice($tag, $string) {
let _element = ~$ctor {
parent: Element::new($type_id, ($tag).to_str()),
$(
$field: None
),*
};
unsafe {
return Node::as_abstract_node(_element);
}
}
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment