zonyitoo / rust-ini

INI file parser in Rust
MIT License
298 stars 76 forks source link

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

Open sorz opened 8 months ago

sorz commented 8 months ago

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.)

zonyitoo commented 8 months ago

Well, yes. It was added from #88 .

zonyitoo commented 8 months ago

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

sorz commented 8 months ago

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?

zonyitoo commented 8 months ago

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).