impero-com / typebinder

Exports TS definitions from Rust module
Other
20 stars 2 forks source link

Use adequate data structure for path mapping #15

Closed AlisCode closed 3 years ago

AlisCode commented 3 years ago

The PathMapper currently uses an HashMap to map path to others. Maybe in the long run we wont need a PathMapper at all, but in the meantime, it sounds like we do.

In a real codebase, this leads to a wonderful path config file of many lines, and that needs to be changed upon refactor. In short, that's no bueno.

We could be a bit smarter and try to match parts of syn::Path to a path. Using a Trie (reference implementation here) sounds like a good idea, I think ?

AlisCode commented 3 years ago

Putting this as a blocker to the 0.1 release on crates.io since the current PathMapper is an ugly hack to say the least.

AlisCode commented 3 years ago

Alright, there was no PR for this because everything was merged on master step by step, but the PathMapper is now a bit cleaner and tested. Closing this.