pub struct NodeId { /* private fields */ }
Expand description
A node identifier within a particular Arena
.
Implementations§
Source§impl NodeId
impl NodeId
pub const ZERO: NodeId
Sourcepub fn new(value: usize) -> Self
pub fn new(value: usize) -> Self
NOTE: In debug mode, it panics on overflow, since having a
pointer that is zero is undefined behaviour (it would basically be
cast to a None
), which is incorrect, so we rather panic on overflow
to prevent that.
To trigger an overflow however, you’d need more that 4 billion DOM nodes - it is more likely that you run out of RAM before you do that. The only thing that could lead to an overflow would be a bug. Therefore, overflow-checking is disabled in release mode.
pub fn index(&self) -> usize
Source§impl NodeId
impl NodeId
Sourcepub const fn ancestors(self, node_hierarchy: &NodeHierarchy) -> Ancestors<'_> ⓘ
pub const fn ancestors(self, node_hierarchy: &NodeHierarchy) -> Ancestors<'_> ⓘ
Return an iterator of references to this node and its ancestors.
Call .next().unwrap()
once on the iterator to skip the node itself.
Sourcepub const fn preceding_siblings(
self,
node_hierarchy: &NodeHierarchy,
) -> PrecedingSiblings<'_> ⓘ
pub const fn preceding_siblings( self, node_hierarchy: &NodeHierarchy, ) -> PrecedingSiblings<'_> ⓘ
Return an iterator of references to this node and the siblings before it.
Call .next().unwrap()
once on the iterator to skip the node itself.
Sourcepub const fn following_siblings(
self,
node_hierarchy: &NodeHierarchy,
) -> FollowingSiblings<'_> ⓘ
pub const fn following_siblings( self, node_hierarchy: &NodeHierarchy, ) -> FollowingSiblings<'_> ⓘ
Return an iterator of references to this node and the siblings after it.
Call .next().unwrap()
once on the iterator to skip the node itself.
Sourcepub fn children(self, node_hierarchy: &NodeHierarchy) -> Children<'_> ⓘ
pub fn children(self, node_hierarchy: &NodeHierarchy) -> Children<'_> ⓘ
Return an iterator of references to this node’s children.
Sourcepub fn reverse_children(
self,
node_hierarchy: &NodeHierarchy,
) -> ReverseChildren<'_> ⓘ
pub fn reverse_children( self, node_hierarchy: &NodeHierarchy, ) -> ReverseChildren<'_> ⓘ
Return an iterator of references to this node’s children, in reverse order.
Sourcepub const fn descendants(
self,
node_hierarchy: &NodeHierarchy,
) -> Descendants<'_> ⓘ
pub const fn descendants( self, node_hierarchy: &NodeHierarchy, ) -> Descendants<'_> ⓘ
Return an iterator of references to this node and its descendants, in tree order.
Parent nodes appear before the descendants.
Call .next().unwrap()
once on the iterator to skip the node itself.
Sourcepub const fn traverse(self, node_hierarchy: &NodeHierarchy) -> Traverse<'_> ⓘ
pub const fn traverse(self, node_hierarchy: &NodeHierarchy) -> Traverse<'_> ⓘ
Return an iterator of references to this node and its descendants, in tree order.
Sourcepub const fn reverse_traverse(
self,
node_hierarchy: &NodeHierarchy,
) -> ReverseTraverse<'_> ⓘ
pub const fn reverse_traverse( self, node_hierarchy: &NodeHierarchy, ) -> ReverseTraverse<'_> ⓘ
Return an iterator of references to this node and its descendants, in tree order.
Trait Implementations§
Source§impl AddAssign<usize> for NodeId
impl AddAssign<usize> for NodeId
Source§fn add_assign(&mut self, other: usize)
fn add_assign(&mut self, other: usize)
+=
operation. Read more