PoiScript / orgize

A Rust library for parsing org-mode files.
https://poiscript.github.io/orgize/
MIT License
277 stars 34 forks source link

derive `PartialEq` #56

Closed smallstepman closed 1 year ago

smallstepman commented 2 years ago

allow to easily extract indextree::NodeId from indextree::Node<Element>, since Arena<T>.get_node_id has where T: PartialEq trait bound (https://docs.rs/indextree/latest/indextree/struct.Arena.html#method.get_node_id)

fn main() {
    let input = orgize::Org::parse("* ASD\ntext");
    let arena = input.arena();

    for node in arena.iter() {
        let id: indextree::NodeId = arena.get_node_id(&node).unwrap();
        println!("{}", id);
    }
}
$ cargo run
1
2
3
4
5
6
7

Edit: users of library crates, usually expect to be able to clone, compare, display, debug, and use stuff as a key in hashmaps (https://rust-lang.github.io/api-guidelines/interoperability.html)