pub struct AstPtr<N: AstNode> { /* private fields */ }
Expand description
Like SyntaxNodePtr
, but remembers the type of node.
Implementations§
source§impl<N: AstNode> AstPtr<N>
impl<N: AstNode> AstPtr<N>
pub fn new(node: &N) -> AstPtr<N>
pub fn to_node(&self, root: &SyntaxNode) -> N
pub fn syntax_node_ptr(&self) -> SyntaxNodePtr
pub fn text_range(&self) -> TextRange
pub fn cast<U: AstNode>(self) -> Option<AstPtr<U>>
pub fn kind(&self) -> SyntaxKind
pub fn upcast<M: AstNode>(self) -> AstPtr<M>where
N: Into<M>,
sourcepub fn try_from_raw(raw: SyntaxNodePtr) -> Option<AstPtr<N>>
pub fn try_from_raw(raw: SyntaxNodePtr) -> Option<AstPtr<N>>
Like SyntaxNodePtr::cast
but the trait bounds work out.
pub fn wrap_left<R>(self) -> AstPtr<Either<N, R>>
pub fn wrap_right<L>(self) -> AstPtr<Either<L, N>>
Trait Implementations§
source§impl<N: AstNode> From<AstPtr<N>> for SyntaxNodePtr
impl<N: AstNode> From<AstPtr<N>> for SyntaxNodePtr
source§fn from(ptr: AstPtr<N>) -> SyntaxNodePtr
fn from(ptr: AstPtr<N>) -> SyntaxNodePtr
Converts to this type from the input type.
impl<N: AstNode> Copy for AstPtr<N>
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
)§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more