Skip to main content

NodeRef

Struct NodeRef 

Source
pub struct NodeRef<'a> { /* private fields */ }
Expand description

节点的引用。可以复制,比较时比的是节点身份。

Implementations§

Source§

impl<'a> NodeRef<'a>

Source

pub fn id(&self) -> NodeId

Source

pub fn document(&self) -> &'a Html<'a>

Source

pub fn parent(&self) -> Option<NodeRef<'a>>

Source

pub fn first_child(&self) -> Option<NodeRef<'a>>

Source

pub fn last_child(&self) -> Option<NodeRef<'a>>

Source

pub fn next_sibling(&self) -> Option<NodeRef<'a>>

Source

pub fn prev_sibling(&self) -> Option<NodeRef<'a>>

Source

pub fn children(&self) -> Children<'a> ⓘ

Source

pub fn descendants(&self) -> Descendants<'a> ⓘ

自身加所有后代,先序(文档顺序)。

Source

pub fn ancestors(&self) -> Ancestors<'a> ⓘ

父节点、祖父节点……直到根,不含自身。

Source

pub fn is_element(&self) -> bool

Source

pub fn is_text(&self) -> bool

Source

pub fn is_comment(&self) -> bool

Source

pub fn is_document(&self) -> bool

Source

pub fn as_element(&self) -> Option<Element<'a>>

Source

pub fn tag(&self) -> Option<Tag>

元素的标签;不是元素时为 None。

Source

pub fn as_text(&self) -> Option<&'a str>

Source

pub fn as_comment(&self) -> Option<&'a str>

Source

pub fn text(&self) -> String

子树里所有文本节点按顺序拼起来。

Source§

impl<'a> NodeRef<'a>

Source

pub fn select<'s>(&self, sel: &'s Selector) -> Select<'a, 's> ⓘ

后代(不含自身)里匹配选择器的元素,按文档顺序;:scope 匹配自身。

Source§

impl NodeRef<'_>

Source

pub fn html(&self) -> String

节点自身及其子树的 HTML(元素的 outer HTML)。

Source

pub fn inner_html(&self) -> String

子节点的 HTML(元素的 inner HTML)。

Trait Implementations§

Source§

impl<'a> Clone for NodeRef<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for NodeRef<'a>

Source§

impl Debug for NodeRef<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for NodeRef<'_>

Source§

impl PartialEq for NodeRef<'_>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

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> UnsafeUnpin for NodeRef<'a>

§

impl<'a> UnwindSafe for NodeRef<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.