Use streaming-iterator for Multipart::foreach_entry
In the documentation for server::Multipart::foreach_iterator, you use an internal iterator due to Rust's iterators not supporting elements that borrow from the iterator. There is a streaming-iterator crate with a StreamingIterator type that properly allows for elements borrowing from the iterator. Would it be possible for you to also support/switch over to using this?
I've been aware of the streaming-iterator crate for a while, but it currently does not support this use-case very well. The problem with the StreamingIterator trait is that it only supports yielding immutable references to items whereas the API I want actually needs a higher-kinded lifetime bound on Self::Item and then binds that lifetime to self on fn next(&mut self); for example, with some hypothetical syntax:
pub trait StreamingIterator {
type Item<'s>;
fn next<'s>(&'s mut self) -> Self::Item<'s>;
}
However, this is currently not supported in the language. The Associated Type Constructors RFC would enable this, but it's still a few steps away from a concrete implementation. I'm sure there's some type system hacks to make this work in current Rust, but I'd rather not overcomplicate the API when it already works as-is (using while let Some(entry) = multipart.next_entry()? {}).