Rust iterator, a design flaw, and towards solutions

Once you have gain some experience with Rust programming language, you will find difficulty trying to implement an iterator interface for your own data class, especially for streaming, e.g. reading through a database, or over internet connection.

You ask, why std::Vec has such a strange iterator type signature, and why can't have its iterator type defined as an associate type, when you think a bit more at the programming language level. It's such a common practice to define associate interface for iterator in other programming languages!

Have you ever tried to make your own iterator without unnecessary copy, and supporting all different kind of iterators, return read-only reference, copy of item, or specify the interface that return type should satisfy?

Read this article http://lukaskalbertodt.github.io/2018/08/03/solving-the-generalized-streaming-iterator-problem-without-gats.html, and start your discovery from https://github.com/yangzhe1990/conflux-rust/blob/no_force_create/core/storage/src/utils/wrap.rs.

We will post a series of articles around this topic.