INNER CODE UNIT · Rust

get_element_by_id

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

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)
}

#[derive(Debug)]
enum EhError {
    NoHits,
    NoWatched,
    NeedLogin,
    NoHathClient,

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…