pub fn recursion(toks: &mut Toks<'_>, handle: Handle)
Expand description
Helper function which walks through html5ever::rcdom::Handle
NodeData::Element
branch recursively and fires Tok``process
function if QualName
is found by is_match
.
Examples found in repository?
examples/goodreads.rs (line 43)
33 34 35 36 37 38 39 40 41 42 43 44 45
fn main() {
let mut chunk = String::new();
io::stdin().read_to_string(&mut chunk).unwrap();
let dom = parse_document(RcDom::default(), Default::default()).one(chunk);
let mut lt = TitleTok;
// Dropping mut reference
{
recursion(&mut vec![&mut lt], dom.document);
}
}
More examples
examples/count_links.rs (line 39)
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
fn main() {
let mut chunk = String::new();
io::stdin().read_to_string(&mut chunk).unwrap();
let dom = parse_document(RcDom::default(), Default::default()).one(chunk);
let mut lt = LinkTok { total: 0 };
// Dropping mut reference
{
recursion(&mut vec![&mut lt], dom.document);
}
println!("Link <a> count {}", lt.total);
}