fn ancestor<'a>(node: &'a ElementRef, height: u32) -> Option<ElementRef<'a>> {

    // Note: Declaring `parent` outside the loop resolves an error
    // regarding dropping to early; however, the compiler reports this as
    // an unused assignment

    let mut curr_node = Deref::deref(node);
    #[allow(unused_assignments)]
    let mut parent = curr_node.parent();
    let mut i = 0;

    while i < height {
        parent = curr_node.parent();
        curr_node = match parent {
            Some(ref node_ref) => node_ref,
            None => { return None; },
        };
        i += 1;
    }

    ElementRef::wrap(*curr_node)
}
// Query for an ancestor node at a given height
Query for an ancestor node at a given height
Query for an ancestor node at a given height
fn ancestor<'a>(node: &'a ElementRef, height: u32) -> Option<ElementRef<'a>> {
    // Note: Declaring `parent` outside the loop resolves an error
    // regarding dropping to early; however, the compiler reports this as
    // an unused assignment
    let mut curr_node = Deref::deref(node);
    #[allow(unused_assignments)]
    let mut parent = curr_node.parent();
    let mut i = 0;
    while i < height {
        parent = curr_node.parent();
        curr_node = match parent {
            Some(ref node_ref) => node_ref,
            None => { return None; },
        };
        i += 1;
    }
    ElementRef::wrap(*curr_node)
}
fn ancestor < ' a > ( node : & ' a ElementRef , height : u32 ) -> Option < ElementRef < ' a > > { // Note: Declaring `parent` outside the loop resolves an error // regarding dropping to early; however, the compiler reports this as // an unused assignment let mut curr_node = Deref :: deref ( node ) ; # [ allow ( unused_assignments ) ] let mut parent = curr_node . parent ( ) ; let mut i = 0 ; while i < height { parent = curr_node . parent ( ) ; curr_node = match parent { Some ( ref node_ref ) => node_ref , None => { return None ; } , } ; i += 1 ; } ElementRef :: wrap ( * curr_node ) }
Query for an ancestor node at a given height
Query for an ancestor node at a given height
node
&'a ElementRef
height
u32