I would like to convert Select.rs's Find
-iterator into a Rayon ParallelIterator
. I haven't been able to do this by simply mucking about with the API. I suspect I shall have to implement or extend a trait, but I have no clue how to do it.
I've tried collecting the Iterator and using into_iter
, but to no avail.
use reqwest;
use rayon::prelude::*;
use select::document::Document;
use select::predicate::{Class};
fn main() {
println!("Hello, world!");
let url = "https://pitchfork.com/reviews/albums/";
let response = reqwest::get(url).unwrap();
if response.status().is_success() {
let document = Document::from_read(response).unwrap();
let albums = document.find(Class("review"));
let albums : Vec<String> = albums.par_iter()
.map(|album| album.text()).collect();
}
}
This results in the error
error[E0599]: no method named `par_iter` found for type `select::document::Find<'_, select::predicate::Class<&str>>` in the current scope
--> src/main.rs:16:40
|
16 | let albums : Vec<String> = albums.par_iter()
| ^^^^^^^^
|
= note: the method `par_iter` exists but the following trait bounds were not satisfied:
`select::document::Find<'_, select::predicate::Class<&str>> : rayon::iter::IntoParallelRefIterator`
I see that the method par_iter
doesn't exist, but it doesn't appear that the method iter
does either.
I assume there is a way of accomplishing this without having to create a pull request to select.rs - either way, assistance would be appreciated.