fn add_to_graph<'arena, Node: Ast<'arena>>(
            node: &'arena Node,
            digraph_edges: &mut String,
            hmap_nodes: &mut HashMap<usize, String>,
        ) {
            let name = node as *const Node as usize;
            if hmap_nodes.get(&name).is_some() {
                return;
            }
            hmap_nodes.insert(
                name,
                format!("node{} [label={:?}]\n", name, node.debug_name()),
            );

            if !node.children().is_empty() {
                for &child in node.children() {
                    add_to_graph(child, digraph_edges, hmap_nodes);
                }

                let edge = format!("node{} -> ", name);
                digraph_edges.push_str(&edge);

                for i in 0..node.children().len() {
                    let child_name = node.children()[i] as *const Node as usize;
                    if i != node.children().len() - 1 {
                        digraph_edges.push_str(&format!("node{}, ", child_name));
                    } else {
                        digraph_edges.push_str(&format!("node{}", child_name));
                    }
                }
                digraph_edges.push('\n');
            }
        }
/// Helper function that recursively builds dot code for the entire subtree of a given node
Helper function that recursively builds dot code for the entire subtree of a given node
Helper function that recursively builds dot code for the entire subtree of a given node
fn add_to_graph<'arena, Node: Ast<'arena>>(
            node: &'arena Node,
            digraph_edges: &mut String,
            hmap_nodes: &mut HashMap<usize, String>,
        ) {
            let name = node as *const Node as usize;
            if hmap_nodes.get(&name).is_some() {
                return;
            }
            hmap_nodes.insert(
                name,
                format!("node{} [label={:?}]\n", name, node.debug_name()),
            );
            if !node.children().is_empty() {
                for &child in node.children() {
                    add_to_graph(child, digraph_edges, hmap_nodes);
                }
                let edge = format!("node{} -> ", name);
                digraph_edges.push_str(&edge);
                for i in 0..node.children().len() {
                    let child_name = node.children()[i] as *const Node as usize;
                    if i != node.children().len() - 1 {
                        digraph_edges.push_str(&format!("node{}, ", child_name));
                    } else {
                        digraph_edges.push_str(&format!("node{}", child_name));
                    }
                }
                digraph_edges.push('\n');
            }
        }
fn add_to_graph < ' arena , Node : Ast < ' arena > > ( node : & ' arena Node , digraph_edges : & mut String , hmap_nodes : & mut HashMap < usize , String > , ) { let name = node as * const Node as usize ; if hmap_nodes . get ( & name ) . is_some ( ) { return ; } hmap_nodes . insert ( name , format ! ( " \n " name node debug_name ( ) ) , ) ; if ! node . children ( ) . is_empty ( ) { for & child in node . children ( ) { add_to_graph ( child , digraph_edges , hmap_nodes ) ; } let edge = format ! ( " " name ) ; digraph_edges . push_str ( & edge ) ; for i in 0 .. node . children ( ) . len ( ) { let child_name = node . children ( ) [ i ] as * const Node as usize ; if i != node . children ( ) . len ( ) - 1 { digraph_edges . push_str ( & format ! ( " " child_name ) ) ; } else { digraph_edges . push_str ( & format ! ( " " child_name ) ) ; } } digraph_edges . push ( '\n' ) ; } }
Helper function that recursively builds dot code for the entire subtree of a given node
Helper function that recursively builds dot code for the entire subtree of a given node
node
&'arena Node
digraph_edges
&mut String
hmap_nodes
&mut HashMap<usize, String>
node
&'arena Node
digraph_edges
&mut String
hmap_nodes
&mut HashMap<usize, String>