macro_rules! get_node {
($graph: expr, $var: path, $idx: expr) => { ... };
}Expand description
Get a node from the graph, assume it is $var variant of the NodeEnum. Returns Option<&NodeType>
ยงExample
use ttgraph::*;
#[derive(TypedNode)]
struct NodeA{
a: usize
}
node_enum!{
enum MyNodeEnum{
A(NodeA)
}
}
let ctx = Context::new();
let mut graph = Graph::<MyNodeEnum>::new(&ctx);
let mut trans = Transaction::new(&ctx);
let x = trans.insert(MyNodeEnum::A(NodeA{ a: 1 }));
graph.commit(trans);
// a: Option<&NodeA>
let a = get_node!(graph, MyNodeEnum::A, x);
assert!(a.is_some());
assert_eq!(a.unwrap().a, 1);