quartiq / miniconf

Rust serialize/deserialize/access reflection for trees (no_std, no alloc)
MIT License
23 stars 2 forks source link

Investigate usage of a suspendable iterator trait #69

Closed ryan-summers closed 2 years ago

ryan-summers commented 2 years ago

Investigate usage of a "suspendable" iterator trait that already exists.

We currently use suspendable iteration by storing the iteration state in an array of [usize] indices. However, it would be useful to use a trait for this that is already defined to make sure we're operating on sound foundations.

Refer to https://github.com/quartiq/miniconf/pull/66#discussion_r766591284 for more information

ryan-summers commented 2 years ago

I discussed this with @jordens earlier and we brought up potentially using a generator, but we came to the agreement that this didn't seem like it would resolve our issue.

After discussion we came to the conclusion that resumable iteration is generally not done because it allows the underlying object to mutate inbetween iterations. For most applications this is undesirable, however in our case, we are cognizant of this issue and know that it is not significant for us.

A potential workaround to this would be to have the Settings structure move into the iterator during republish, which would prevent modification of settings during iteration, but so far, we are not aware of any issues resulting from this behavior. Closing as no change needed.