#[non_exhaustive]pub struct NodeRef(/* private fields */);
Expand description
A reference to an HTML node.
Implementations§
Source§impl NodeRef
impl NodeRef
Sourcepub 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).
Sourcepub 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
.
Sourcepub 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.
Sourcepub 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.
Sourcepub 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.
Sourcepub fn has_children(&self) -> bool
pub fn has_children(&self) -> bool
Whether this node has children.
Sourcepub 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.
Sourcepub 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,
§impl<T> CompatExt for T
impl<T> CompatExt for T
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more