Closed andrewebdev closed 1 year ago
Okay, turns out that was simpler than I thought in the end:
let zeroth = org.document().section_node().unwrap();
for node_id in zeroth.children(org.arena()) {
let node = org.arena().get(node_id).unwrap();
let data = node.get();
match data {
Element::Drawer(d) => {
println!("\nData? {d:?}");
},
_ => {}
}
}
Hi, firstly apologies for the newbie question. I'm new to rust and still learning.
I'm writing a tool that uses orgize. I'm attempting to extract only the properties from the Zeroth section of the org-mode file. My problem is that the iterator returns an indextree Arena and I don't know how to match it against "Element::Drawer" from the arena. Do I have to make some kind of type inference or typecast for this to work?
Here is my code currently:
Of course the code above does not work because the
node
and theElement::Drawer
isn't the same type. How could I match against specific element types when traversing a sub-section of the tree as I have above?