charlesvdv / nom-bibtex

A feature complete bibtex parser using nom
https://docs.rs/nom-bibtex
MIT License
24 stars 15 forks source link

Use a HashMap instead of Vec<(String, String)> for variables #22

Closed A6GibKm closed 1 year ago

A6GibKm commented 1 year ago

I have a patch for this that I am using for Citations, would you be interested in this?

charlesvdv commented 1 year ago

Honestly, I don't remember why I didn't use a HashMap instead of a Vec of tuples..

If this can avoid a potential fork, I guess I would prefer to have this integrated in the crate directly. It would also match a bit better with the semantic of a variable (only one value defined per variable). So, I would be open to the idea even if it mean a breaking change to the API.

A6GibKm commented 1 year ago

At this point I removed my use of a fork and just do

        let tags: HashMap<String, String> = bib
            .tags()
            .iter()
            .map(|(k, v)| (k.to_lowercase(), v.clone()))
            .collect();

doing the allocations is a bit unfortunate, but it is what it is. Ill try to post the patches during the week.