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
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)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)