utkarshkukreti / select.rs

A Rust library to extract useful data from HTML documents, suitable for web scraping.
MIT License
971 stars 69 forks source link

How to pass a Selection into a function? #6

Closed vm closed 8 years ago

vm commented 8 years ago

Hi!

Was wondering if you could explain a bit how to do something like this signature.

fn parse_row(row: Selection) -> Option<String>

For now I am getting lifetime errors that I'm not able to fix using the source code. Let me know, thanks!

utkarshkukreti commented 8 years ago

What error are you getting? Does this work:

fn parse_row<'a>(row: Selection<'a>) -> Option<String> {
    Some("foo".into())
}

?

vm commented 8 years ago

That helped! Sorry about that, looks like all I forgot to do was do impl<'a> X<'a> instead of impl X<'a>. Thanks again for a great library!