INNER CODE UNIT · Rust

get_first_child

FooIbar/EhViewer · app/src/main/rust/src/lib.rs:52

fn get_first_child<'a>(tag: &'a HTMLTag, parser: &'a Parser) -> Option<&'a HTMLTag<'a>> {
    tag.children()
        .top()
        .iter()
        .find_map(|n| n.get(parser)?.as_tag())
}

fn get_element_by_id<'b, S>(node: &'b Node, parser: &'b Parser, id: S) -> Option<&'b Node<'b>>
where
    S: Into<Bytes<'b>>,
{
    let bytes: Bytes = id.into();
    let handle = node.find_node(parser, &mut |n| match n.as_tag() {
        None => false,
        Some(tag) => tag.attributes().id().is_some_and(|x| x.eq(&bytes)),
    })?;
    handle.get(parser)
}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…