I'm using the select library to parse an HTML table into a stream of Data
structures.
Ideally I would like to write a function that downloads the HTML, parses it and returns an iterator. Something like this:
fn get_data_iterator(...) -> impl Iterator<Data> {
let doc = Document::from_read(...).unwrap();
doc.find(Name("tr")).map(tr_to_data)
}
However, doc.find()
returns an Find<'a, P>
which is bound to the lifetime of doc
.
Is there a way to package doc
with the returned iterator so that it lives as long as the iterator?
I tried writing a proxy iterator struct that would contain both doc
and the iterator created with doc.find
, but I couldn't find a way to do that correctly.