rust-ini icon indicating copy to clipboard operation
rust-ini copied to clipboard

Ini::iter always return general section even it's empty since 0.19

Open sorz opened this issue 1 year ago • 4 comments

I'm not sure if this change is intended or introduced by accident (by #88 I guess).

0.18 and before: Ini::new().next() is None

0.19 and after: Ini::new().next() is Some((None, Properties { data: {} }))

(P.S I was iterating all sections from user-generated ini file and prohibited empty section. This change break the logic since now there is always a empty general section.)

sorz avatar Jan 09 '24 09:01 sorz

Well, yes. It was added from #88 .

zonyitoo avatar Jan 09 '24 13:01 zonyitoo

Maybe we can add a Ini::new_empty() method to create a truely empty Ini?

zonyitoo avatar Jan 09 '24 13:01 zonyitoo

It also affects, for example, Ini::load_from_file: a file consisting solely of named sections appears to have an empty general group in its iterator.

We might add a check in the iterator impl to not yield an empty general group?

sorz avatar Jan 09 '24 16:01 sorz

We might add a check in the iterator impl to not yield an empty general group?

It looks like a good solution that wouldn't break compatibility (maybe).

zonyitoo avatar Jan 12 '24 13:01 zonyitoo