Skip to content
This repository has been archived by the owner on Feb 14, 2023. It is now read-only.

Use streaming-iterator for Multipart::foreach_entry #85

Open
bb010g opened this issue Jul 3, 2017 · 1 comment
Open

Use streaming-iterator for Multipart::foreach_entry #85

bb010g opened this issue Jul 3, 2017 · 1 comment

Comments

@bb010g
Copy link

bb010g commented Jul 3, 2017

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?

@abonander
Copy link
Owner

abonander commented Jul 3, 2017

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()? {}).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants