@dontblink Looks like there's some weird stuff between my instance and yours in the formatting. There shouldn't be any backslashes anywhere
gigapixel
joined 2 years ago
@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:
link\_nodes.into\_iter().filter\_map(|node| node.value().attr("href")).map(String::from).next()
@dontblink If you really want to do it in a loop, you could do something like
That said, your function name suggest you want _all_ links, so some kind of collection of links. Is this the case?