Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to generate code with IndexMap instead of HashMap #555

Open
jon-zu opened this issue Apr 15, 2024 · 3 comments
Open

Add option to generate code with IndexMap instead of HashMap #555

jon-zu opened this issue Apr 15, 2024 · 3 comments

Comments

@jon-zu
Copy link

jon-zu commented Apr 15, 2024

Sometimes It's required to preserve the order, If we could add a flag to generate code with IndexMap instead of HashMap .
We could also just utilize serde_json::Map so It'd respect the serde_json feature flag.

@ahl
Copy link
Collaborator

ahl commented Apr 18, 2024

Perhaps a generic "specify Map type" kind of setting? Some folks would prefer BTreeMap to HashMap so it might be nice to just allow this to be specified generically. I suppose we could do this for arrays and sets as well.

@jon-zu
Copy link
Author

jon-zu commented May 2, 2024

A special map type via settings is also a good choice, however It's somewhat convenient (can be also confusing ofc) that serde_json::Map is controlled over the feature flag in the Cargo.toml. So maybe allowing 3 options(Default, serde_json or custom) would be a decent setting. I can try to get a cli option working for this next week and make a pull request.

@ahl
Copy link
Collaborator

ahl commented May 2, 2024

I'd welcome a pull request here. My suggestion is to provide an option for all modes (builder, macro, CLI) that lets you specify the fully qualified path of the map type you'd like. The assumption would be that it would be a type of the form T<K,V> that supports typical map-like operations (it would be nice in the docs if we specify what those map-like operations are specifically).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants