I'm using Kuchiki to parse some HTML and making HTTP requests using hyper to concurrently operate on results through scoped_threadpool.
I select and iterate over listings. I decide the number of threads to allocate in the threadpool based on the number of listings:
let listings = document.select("table.listings").unwrap();
let mut pool = Pool::new(listings.count() as u32);
pool.scoped(|scope| {
for listing in listings {
do_stuff_with(listing);
}
});
When I try to do this I get capture of moved value: listings
. listings
is kuchiki::iter::Select<kuchiki::iter::Elements<kuchiki::iter::Descendants>>
, which is non-copyable -- so I get neither an implicit clone nor an explicit .clone
.
Inside the pool I can just do document.select("table.listings")
again and it will work, but this seems unnecessary to me since I already used it to get the count. I don't need listings
after the loop either.
Is there any way for me to use a non-copyable value in a closure?