The playground example produces the error
error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates --> src/main.rs:25:6 For more information about this error, try `rustc --explain E0207`.
There are no generics involved; this is a complaint about lifetime issues only. The explanation for error E0207 is focused on a similar error involving generics.
Motivation: The goal is to put a reference to a data item into a struct, then use a function associated with the struct as an iterator over the data item, returning references to parts of the original data item.. My goal is to parse a message buffer with multiple messages, and generate data structures of the parse without allocating on the heap. Most of the time, the parsed message is acted upon and discarded; sometimes it has to be cloned and saved.
I'm doing this now with a callback function, but I wanted to do it with an iterator, which would simplify the control flow.
The example is just something simple to figure out how to do this in Rust.