#[non_exhaustive]pub struct NodeRef<'a> { /* private fields */ }
Available on crate feature
html
only.Expand description
A reference to an HTML node.
Implementations§
§impl<'a> NodeRef<'a>
impl<'a> NodeRef<'a>
pub fn as_element(&self) -> Option<&'a ElementData>
pub fn as_element(&self) -> Option<&'a ElementData>
Returns the data of this node if it is a NodeData::Element
.
pub fn as_text(&self) -> Option<&'a Tendril<UTF8>>
pub fn as_text(&self) -> Option<&'a Tendril<UTF8>>
Returns the text content of this node, if it is a NodeData::Text
.
pub fn parent(&self) -> Option<NodeRef<'a>>
pub fn parent(&self) -> Option<NodeRef<'a>>
The parent node of this node.
Returns None
if the parent is the root node.
pub fn next_sibling(&self) -> Option<NodeRef<'a>>
pub fn next_sibling(&self) -> Option<NodeRef<'a>>
The next sibling node of this node.
Returns None
if this is the last of its siblings.
pub fn prev_sibling(&self) -> Option<NodeRef<'a>>
pub fn prev_sibling(&self) -> Option<NodeRef<'a>>
The previous sibling node of this node.
Returns None
if this is the first of its siblings.
pub fn has_children(&self) -> bool
pub fn has_children(&self) -> bool
Whether this node has children.
pub fn first_child(&self) -> Option<NodeRef<'a>>
pub fn first_child(&self) -> Option<NodeRef<'a>>
The first child node of this node.
Returns None
if this node has no children.
pub fn last_child(&self) -> Option<NodeRef<'a>>
pub fn last_child(&self) -> Option<NodeRef<'a>>
The last child node of this node.
Returns None
if this node has no children.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for NodeRef<'a>
impl<'a> !RefUnwindSafe for NodeRef<'a>
impl<'a> !Send for NodeRef<'a>
impl<'a> !Sync for NodeRef<'a>
impl<'a> Unpin for NodeRef<'a>
impl<'a> !UnwindSafe for NodeRef<'a>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)