Added an accessible array of field names to DocumentedFields #15
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello, I found your crate while looking for a way to make a struct to deserialize a config file, that I could automatically generate a documentation for said file from by using its fields' docs. Your crate was very close to allowing that but still required to hardcode the field names in order to access their documentation. I thought that since it used those field names already, it would be trivial to store them alongside the docs and make them accessible. And indeed it was.
I don't know if anyone else needs this feature. I would have thought so but I'm surprised by the lack of result while searching for it. Regardless, as far as I can tell this PR doesn't induce any backwards-incompatible changes, so might as well share my patch.
I chose to account for unnamed fields by just omitting them from the array, simplifying access but breaking the field name <=> doc index match (i.e you can't just zip() them), on account of the fact that you can always use get_field_docs to map name to docs. If you prefer an alternate implementation (array of
Optional
s, empty names or other sentinel value for unnamed fields, etc…) I don't mind adjusting it.I can also try and put this behind a feature flag if you prefer.