@dontblink The idea of the iterator is to assemble all of your computation lazily and only perform it at the final step. In this case you don't actually perform any the actions until you call collect, which essentially creates a loop that goes through the original Select and performs the calculations and pushes the results to a Vec.
@dontblink For stuff like this, I tend to prefer rusts iterator combinators, but I admit it's a bit more advanced. So in this case you'd do
fn get\_links(link\_nodes: scraper::html::Select\<'\_, '\_\>) -\> Vec\<String\> {
link\_nodes
.into\_iter() // convert select to iterator
.filter\_map(|node| node.value().attr("href")) // only select nodes with an href attribute, and select that value
.map(ToString::to\_string) // map that value to a string
.collect()
}
@dontblink Here's a little explanation for the methods into\_iter : converts Select into an iterator (a for loop does this implicitly) filter\_map: takes an iterator and constructs an iterator from an Fn(T) -\> Option\<S\> where the emitted elements are the elements for which applying the function/closure is Some next: takes the next element of the iterator as an Option.
@dontblink It's a little unclear what you want to do. It looks like Select implements into iterator. As far as I can parse your code you want to get the first node with a href element. In that case you should do:
@dontblink It feels like you should never
OsResponseType::Bool(true)
so you could probably encode that in the enum just as the sameUnrecognised