-
Notifications
You must be signed in to change notification settings - Fork 2
Description
I require the EDN tree to have span information associated with each node. I started working on this feature already in a fork, but I cannot find a "clean" enough solution and was hoping to hear your advice if you have any, in case you are interested in merging such a feature.
-
Adding a span field to each enum variant of
Ednmakes the use of theEdn's impls function slightly annoying since they are not designed to be aware of spans.
examples/get-nth.rs:15:edn - .get(&Edn::Key("foo"))? - .get(&Edn::Symbol("猫"))? - .get(&Edn::Map(BTreeMap::from([(Edn::Key("foo"), Edn::Key("bar"))])))? + .get(&Edn::Key("foo", new_span()))? + .get(&Edn::Symbol("猫", new_span()))? + .get(&Edn::Map( + BTreeMap::from([(Edn::Key("foo", new_span()), Edn::Key("bar", new_span()))]), + new_span(), + ))? .nth(2)
Already added a manual Hash impl so hash of Edn doesn't depend on spans
-
If each of the atom variants held a raw string-slice like
Key,Symbol&Strdo, it would be possible to produce a better spanned tree from the implementor's side by reverse-engineering it using<*const str>::addr, thought its a hacky solution for something that could be provided by the library
Is having two different enums, Edn and EdnSpanned feasible? In this case the Edn impl functions would remain on Edn, but the parser would produce EdnSpanneds.