configparser-rs icon indicating copy to clipboard operation
configparser-rs copied to clipboard

Iterate over the keys of a section request.

Open djve60 opened this issue 3 years ago • 3 comments

I have a set of keys in an ini file in once section that I need to apply the same rules to and update the data structure, in memory.

With the current code base I need to know the keys in advance. I would by much nicer if I could do something like:

for key in config.get_keys("section_name") { //do something here. }

Then, with the sections() function dumping the data while debugging is also trivial.

djve60 avatar Aug 26 '22 21:08 djve60

@djve60 The underlying impl is a HashMap you can iterate over the keys by simply using the underlying hashmap. But you are correct, we should have a function to return a section, I'll plan it for next release.

QEDK avatar Aug 29 '22 07:08 QEDK

Yes, I'm using iteration before I posted. That's why it's just an enhancement/new feature. But to match the sections() I felt that there should be a matching keys(). Glad you agree. It's not stopping my code but I'll update when the new call is ready.

Thanks!

djve60 avatar Aug 29 '22 15:08 djve60