// TODO make an MRE for it
fn build_tree(
rep: &[u8],
i: &mut usize,
parent: Option<&String>,
tree: &mut ViewTree<String, Custom>,
) -> Option<()> {
let acceptable = b"( ,)";
let mut is_gathering = true;
let mut buf = String::with_capacity(3);
let mut node = parent;
while *i < rep.len() {
let x = rep[*i];
if is_gathering {
if x.is_ascii_alphanumeric() {
buf.push(x as char);
*i += 1;
} else if acceptable.contains(&x) {
tree.add_child_node(buf.clone(), parent, Custom {
state: State::Pending,
name: format!("{}_payload", buf)
});
node = Some(&buf);
buf.clear();
is_gathering = false;
} else {
return None;
}
} else {
}
}
Some(())
}
Comments
0 B
|👍
/👎
0 B
|👍
/👎