Function dynparser::ast::flat::split_first_nodes
source · Expand description
Given a list of nodes, return the first and the rest on a tuple
use dynparser::ast::flat;
let nodes = vec![
flat::Node::Val("hello".to_string()),
flat::Node::Val("world".to_string()),
flat::Node::Val(".".to_string()),
];
let (node, nodes) = flat::split_first_nodes(&nodes).unwrap();
assert!(flat::get_node_val(node).unwrap() == "hello");
assert!(nodes.len() == 2);
let (node, nodes) = flat::split_first_nodes(&nodes).unwrap();
assert!(flat::get_node_val(node).unwrap() == "world");
assert!(nodes.len() == 1);
let (node, nodes) = flat::split_first_nodes(&nodes).unwrap();
assert!(flat::get_node_val(node).unwrap() == ".");
assert!(nodes.len() == 0);