pub struct AstPtr<N: AstNode> { /* private fields */ }Expand description
Like SyntaxNodePtr, but remembers the type of node.
§Note
As with SyntaxNodePtr, this must not be used on mutable
syntax trees, since any mutation can cause the pointed node’s
source location to change, invalidating the pointer
Implementations§
Source§impl<N: AstNode> AstPtr<N>
impl<N: AstNode> AstPtr<N>
Sourcepub fn new(node: &N) -> Self
pub fn new(node: &N) -> Self
Returns an AstPtr for the node.
Panics if the provided node is mutable
Sourcepub fn to_node(&self, root: &SyntaxNode<N::Language>) -> N
pub fn to_node(&self, root: &SyntaxNode<N::Language>) -> N
Like Self::try_to_node but panics on failure.
Sourcepub fn try_to_node(&self, root: &SyntaxNode<N::Language>) -> Option<N>
pub fn try_to_node(&self, root: &SyntaxNode<N::Language>) -> Option<N>
Given the root node containing the node n that self is a pointer to,
returns n if possible. Panics if root is mutable. See SyntaxNodePtr::try_to_node.
Sourcepub fn syntax_node_ptr(&self) -> SyntaxNodePtr<N::Language>
pub fn syntax_node_ptr(&self) -> SyntaxNodePtr<N::Language>
Returns the underlying SyntaxNodePtr.
Trait Implementations§
impl<N: AstNode> Eq for AstPtr<N>
Auto Trait Implementations§
impl<N> Freeze for AstPtr<N>
impl<N> RefUnwindSafe for AstPtr<N>
impl<N> Send for AstPtr<N>
impl<N> Sync for AstPtr<N>
impl<N> Unpin for AstPtr<N>
impl<N> UnwindSafe for AstPtr<N>
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