Struct NodeRef
#[non_exhaustive]pub struct NodeRef(/* private fields */);
Available on crate feature
html
only.Expand description
A reference to an HTML node.
Implementations§
§impl NodeRef
impl NodeRef
pub fn as_element(&self) -> Option<&ElementData>
pub fn as_element(&self) -> Option<&ElementData>
Returns the data of this Node
if it is an Element (aka an HTML tag).
pub fn as_text(&self) -> Option<&RefCell<Tendril<UTF8>>>
pub fn as_text(&self) -> Option<&RefCell<Tendril<UTF8>>>
Returns the text content of this Node
, if it is a NodeData::Text
.
pub fn parent(&self) -> Option<NodeRef>
pub fn parent(&self) -> Option<NodeRef>
The parent node of this node.
Returns None
if the parent is the root node.
pub fn next_sibling(&self) -> Option<NodeRef>
pub fn next_sibling(&self) -> Option<NodeRef>
The next sibling node of this node.
Returns None
if this is the last of its siblings.
pub fn prev_sibling(&self) -> Option<NodeRef>
pub fn prev_sibling(&self) -> Option<NodeRef>
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>
pub fn first_child(&self) -> Option<NodeRef>
The first child node of this node.
Returns None
if this node has no children.
pub fn last_child(&self) -> Option<NodeRef>
pub fn last_child(&self) -> Option<NodeRef>
The last child node of this node.
Returns None
if this node has no children.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for NodeRef
impl !RefUnwindSafe for NodeRef
impl !Send for NodeRef
impl !Sync for NodeRef
impl Unpin for NodeRef
impl !UnwindSafe for NodeRef
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§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
)