Derive Macro lang_util_derive::NodeContent[][src]

#[derive(NodeContent)]
{
    // Attributes available to this derive:
    #[lang_util]
}

Mark a type as representing data in an AST node

Examples

If the name of the data structure doesn’t end with Data, the lang_util::NodeContent trait will just be implemented for that type.

use lang_util_derive::NodeContent;

#[derive(NodeContent)]
pub struct Declaration {
    pub name: String,
}

If the name of the data structure ends with Data, the lang_util::NodeContent trait will be implemented for that type, and a type alias for Node<T> will be declared for the suffix-less name.

use lang_util_derive::NodeContent;

#[derive(NodeContent)]
pub struct DeclarationData {
    pub name: String,
}

// Will declare pub type Declaration = ::lang_util::node::Node<DeclarationData>;