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 moreSource§impl<T> Index<NodeId> for NodeDataContainer<T>
impl<T> Index<NodeId> for NodeDataContainer<T>
Source§impl Index<NodeId> for NodeHierarchy
impl Index<NodeId> for NodeHierarchy
Source§impl<T> IndexMut<NodeId> for NodeDataContainer<T>
impl<T> IndexMut<NodeId> for NodeDataContainer<T>
Source§impl IndexMut<NodeId> for NodeHierarchy
impl IndexMut<NodeId> for NodeHierarchy
Source§impl Ord for NodeId
impl Ord for NodeId
Source§impl PartialOrd for NodeId
impl PartialOrd for NodeId
impl Copy for NodeId
impl Eq for NodeId
impl StructuralPartialEq for NodeId
Auto Trait Implementations§
impl Freeze for NodeId
impl RefUnwindSafe for NodeId
impl Send for NodeId
impl Sync for NodeId
impl Unpin for NodeId
impl UnwindSafe for NodeId
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
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)
clone_to_uninit
)