Parser
More convenient ways to define nodes and build the graph.
Auto implementation for Node trait
Implementing the Node trait for tons of custom types is a bit of a waste of time.
for example you need to implement the id method for all of them, which just return
a NodeId but you have to write such code over and over again.
Dagrs provides the procedural macro
auto_node to simplify implementing the Node trait for custom types. As the following example
goes, macro auto_node will add neccery fields to your custom type, and implement the
Node trait for this type.
use dagrs::{auto_node}
#[auto_node]
struct MyNode {/*Put customized fields here.*/}
#[auto_node]
struct MyNodeGeneric<T, 'a> {
my_field: Vec<T>,
my_name: &'a str,
}
#[auto_node]
struct MyUnitNode;
Note:
The macro auto_node currently doen't work on tuple structs.