pub enum HirNode<'hir> {
Undefined,
Root(&'hir HirRoot<'hir>),
Text(&'hir HirText<'hir>),
Internal(&'hir HirInternal<'hir>),
Scope(&'hir HirScope<'hir>),
File(&'hir HirFile<'hir>),
Ident(&'hir HirIdent<'hir>),
}Variants§
Undefined
Root(&'hir HirRoot<'hir>)
Text(&'hir HirText<'hir>)
Internal(&'hir HirInternal<'hir>)
Scope(&'hir HirScope<'hir>)
File(&'hir HirFile<'hir>)
Ident(&'hir HirIdent<'hir>)
Implementations§
Source§impl<'hir> HirNode<'hir>
impl<'hir> HirNode<'hir>
pub fn format_node(&self, unit: CompileUnit<'hir>) -> String
pub fn field_id(&self) -> u16
pub fn kind_id(&self) -> u16
pub fn hir_id(&self) -> HirId
pub fn start_byte(&self) -> usize
pub fn end_byte(&self) -> usize
pub fn child_count(&self) -> usize
pub fn inner_ts_node(&self) -> Node<'hir>
pub fn parent(&self) -> Option<HirId>
pub fn opt_child_by_field( &self, unit: CompileUnit<'hir>, field_id: u16, ) -> Option<HirNode<'hir>>
pub fn child_by_field( &self, unit: CompileUnit<'hir>, field_id: u16, ) -> HirNode<'hir>
pub fn expect_ident_child_by_field( &self, unit: CompileUnit<'hir>, field_id: u16, ) -> &'hir HirIdent<'hir>
pub fn opt_child_by_kind( &self, unit: CompileUnit<'hir>, kind_id: u16, ) -> Option<HirNode<'hir>>
pub fn child_by_kind( &self, unit: CompileUnit<'hir>, kind_id: u16, ) -> HirNode<'hir>
Sourcepub fn find_ident(
&self,
unit: CompileUnit<'hir>,
) -> Option<&'hir HirIdent<'hir>>
pub fn find_ident( &self, unit: CompileUnit<'hir>, ) -> Option<&'hir HirIdent<'hir>>
Recursively search for an identifier within this node.
Useful for finding the actual identifier in complex AST nodes like generic_type
that wrap the identifier. For example, in impl<'tcx> Holder<'tcx>, the type
field points to a generic_type node, which contains the type_identifier “Holder”.
Source§impl<'hir> HirNode<'hir>
impl<'hir> HirNode<'hir>
pub fn as_root(&self) -> Option<&'hir HirRoot<'hir>>
pub fn expect_root(&self) -> &'hir HirRoot<'hir>
pub fn is_root(&self) -> bool
pub fn as_text(&self) -> Option<&'hir HirText<'hir>>
pub fn expect_text(&self) -> &'hir HirText<'hir>
pub fn is_text(&self) -> bool
pub fn as_internal(&self) -> Option<&'hir HirInternal<'hir>>
pub fn expect_internal(&self) -> &'hir HirInternal<'hir>
pub fn is_internal(&self) -> bool
pub fn as_scope(&self) -> Option<&'hir HirScope<'hir>>
pub fn expect_scope(&self) -> &'hir HirScope<'hir>
pub fn is_scope(&self) -> bool
pub fn as_file(&self) -> Option<&'hir HirFile<'hir>>
pub fn expect_file(&self) -> &'hir HirFile<'hir>
pub fn is_file(&self) -> bool
pub fn as_ident(&self) -> Option<&'hir HirIdent<'hir>>
pub fn expect_ident(&self) -> &'hir HirIdent<'hir>
pub fn is_ident(&self) -> bool
Trait Implementations§
impl<'hir> Copy for HirNode<'hir>
Auto Trait Implementations§
impl<'hir> Freeze for HirNode<'hir>
impl<'hir> RefUnwindSafe for HirNode<'hir>
impl<'hir> Send for HirNode<'hir>
impl<'hir> Sync for HirNode<'hir>
impl<'hir> Unpin for HirNode<'hir>
impl<'hir> UnwindSafe for HirNode<'hir>
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§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