Lending iterator trait and declarative macro for iteration

Since I found myself in the need to have lending iterators, which are exclusively used in for-loops like iteration, i.e. while let Some(…) = iter.next() { … } I whipped up a generic lending iterator trait and a declarative macro to facilitate iteration over iterator expressions.

The purpose of the macro is to improve ergonomics to not need to instantiate the iterator in a mutable variable manually each time and then call next() on it (and not accidentally re-instantiate the iterator on each iteration causing an infinite looping over the first item).

What are your thoughts on this?

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.