-
Notifications
You must be signed in to change notification settings - Fork 21
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
Support sections with no keys #37
Comments
This is an interesting edge-case, let me look into the parser implementation. |
The issue would arise from our handling of section headers, Line 486 in 1098ef7
HashMap<String, Option<HashMap<String, Option<String>>>> .
|
My use-case is a bit of a weird one actually. I'm using this library to parse an "ini-like" file format, which uses double-brackets to signify a higher level section, for example this:
should result in this hierarchy after parsing: graph TD;
Section1-->subsectionA-->keys1{{key=value}};
Section2-->subsectionB-->keys2{{key=value}};
This is not strictly INI, but Currently this not working is not a big issue for me, so if it's impacting a library design or backwards compatibility I guess it's fine to close this issue and I'll have to stop being lazy and write some proper parser instead :) |
I've got an implementation in #50. I was able to do it without changing the API by just creating an empty HashMap when we encounter the section header, which seems clear enough - people who need to know about that edge case would be able to check if the hash map's Our use case is that having sections means that something is enabled, and allowing for extra configuration as options in that section. An empty section would mean it was enabled but there was no additional configuration. |
Currently when I read this file:
the resulting map (and
conf.sections()
too) will only containsection1
.section0
will be silently dropped.I didn't find any way to configure this crate so that sections with no keys are not skipped.
There are some use-cases where one wants to know if section is present (even if empty).
The text was updated successfully, but these errors were encountered: