rust-ini
rust-ini copied to clipboard
Comments are not kept after write_to_file
[a_section]
a=1
#b=1
after write_to_file
is called we end up with:
[a_section]
a=1
Yup.. Comments are not kept after parsed. Any PRs are welcome.
cool, could you please suggest an implementation strategy?
I have no idea how to implement that gracefully, because comments may not be followed by a key-value pairs, or a section header, how to store it?
Do you know any other INI libraries that could kept comments after parsing? @lrascao
I'm not familiar with rust-ini, but based on this issue alone, I assume it works by mapping the whole file on read, and flushing the whole structure into a file on write. Which will probably bite you when dealing with big files, so it may not be the best approach.
From Bash I use crudini which is in Python so prolly not much of a help, but who knows. All I know is it works just fine with comments. Basically it doesn't care about irrelevant sections in the file, or irrelevant lines in the section either. It touches only the parts you tell it touch.