pub enum Node<'hir> {
Show 25 variants
Param(&'hir Param<'hir>),
Item(&'hir Item<'hir>),
ForeignItem(&'hir ForeignItem<'hir>),
TraitItem(&'hir TraitItem<'hir>),
ImplItem(&'hir ImplItem<'hir>),
Variant(&'hir Variant<'hir>),
Field(&'hir FieldDef<'hir>),
AnonConst(&'hir AnonConst),
Expr(&'hir Expr<'hir>),
ExprField(&'hir ExprField<'hir>),
Stmt(&'hir Stmt<'hir>),
PathSegment(&'hir PathSegment<'hir>),
Ty(&'hir Ty<'hir>),
TypeBinding(&'hir TypeBinding<'hir>),
TraitRef(&'hir TraitRef<'hir>),
Pat(&'hir Pat<'hir>),
PatField(&'hir PatField<'hir>),
Arm(&'hir Arm<'hir>),
Block(&'hir Block<'hir>),
Local(&'hir Local<'hir>),
Ctor(&'hir VariantData<'hir>),
Lifetime(&'hir Lifetime),
GenericParam(&'hir GenericParam<'hir>),
Crate(&'hir Mod<'hir>),
Infer(&'hir InferArg),
}
Variants
Param(&'hir Param<'hir>)
Item(&'hir Item<'hir>)
ForeignItem(&'hir ForeignItem<'hir>)
TraitItem(&'hir TraitItem<'hir>)
ImplItem(&'hir ImplItem<'hir>)
Variant(&'hir Variant<'hir>)
Field(&'hir FieldDef<'hir>)
AnonConst(&'hir AnonConst)
Expr(&'hir Expr<'hir>)
ExprField(&'hir ExprField<'hir>)
Stmt(&'hir Stmt<'hir>)
PathSegment(&'hir PathSegment<'hir>)
Ty(&'hir Ty<'hir>)
TypeBinding(&'hir TypeBinding<'hir>)
TraitRef(&'hir TraitRef<'hir>)
Pat(&'hir Pat<'hir>)
PatField(&'hir PatField<'hir>)
Arm(&'hir Arm<'hir>)
Block(&'hir Block<'hir>)
Local(&'hir Local<'hir>)
Ctor(&'hir VariantData<'hir>)
Ctor
refers to the constructor of an enum variant or struct. Only tuple or unit variants
with synthesized constructors.
Lifetime(&'hir Lifetime)
GenericParam(&'hir GenericParam<'hir>)
Crate(&'hir Mod<'hir>)
Infer(&'hir InferArg)
Implementations
sourceimpl<'hir> Node<'hir>
impl<'hir> Node<'hir>
sourcepub fn ident(&self) -> Option<Ident>
pub fn ident(&self) -> Option<Ident>
Get the identifier of this Node
, if applicable.
Edge cases
Calling .ident()
on a Node::Ctor
will return None
because Ctor
s do not have identifiers themselves.
Instead, call .ident()
on the parent struct/variant, like so:
ⓘ
ctor
.ctor_hir_id()
.and_then(|ctor_id| tcx.hir().find(tcx.hir().get_parent_node(ctor_id)))
.and_then(|parent| parent.ident())
pub fn fn_decl(self) -> Option<&'hir FnDecl<'hir>>
pub fn fn_sig(self) -> Option<&'hir FnSig<'hir>>
pub fn body_id(&self) -> Option<BodyId>
pub fn generics(self) -> Option<&'hir Generics<'hir>>
pub fn as_owner(self) -> Option<OwnerNode<'hir>>
pub fn fn_kind(self) -> Option<FnKind<'hir>>
sourcepub fn tuple_fields(&self) -> Option<&'hir [FieldDef<'hir>]>
pub fn tuple_fields(&self) -> Option<&'hir [FieldDef<'hir>]>
Get the fields for the tuple-constructor, if this node is a tuple constructor, otherwise None
Trait Implementations
sourceimpl<'hir, __CTX> HashStable<__CTX> for Node<'hir>where
__CTX: HashStableContext,
impl<'hir, __CTX> HashStable<__CTX> for Node<'hir>where
__CTX: HashStableContext,
fn hash_stable(&self, __hcx: &mut __CTX, __hasher: &mut StableHasher)
impl<'hir> Copy for Node<'hir>
Auto Trait Implementations
impl<'hir> !RefUnwindSafe for Node<'hir>
impl<'hir> !Send for Node<'hir>
impl<'hir> !Sync for Node<'hir>
impl<'hir> Unpin for Node<'hir>
impl<'hir> !UnwindSafe for Node<'hir>
Blanket Implementations
sourceimpl<'tcx, T> ArenaAllocatable<'tcx, IsCopy> for Twhere
T: Copy,
impl<'tcx, T> ArenaAllocatable<'tcx, IsCopy> for Twhere
T: Copy,
fn allocate_on(self, arena: &'a Arena<'tcx>) -> &'a mut T
fn allocate_from_iter(
arena: &'a Arena<'tcx>,
iter: impl IntoIterator<Item = T>
) -> &'a mut [T]ⓘNotable traits for &[u8]impl Read for &[u8]impl Write for &mut [u8]
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Layout
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference’s “Type Layout” chapter for details on type layout guarantees.
Size: 16 bytes
Size for each variant:
Param
: 8 bytesItem
: 8 bytesForeignItem
: 8 bytesTraitItem
: 8 bytesImplItem
: 8 bytesVariant
: 8 bytesField
: 8 bytesAnonConst
: 8 bytesExpr
: 8 bytesExprField
: 8 bytesStmt
: 8 bytesPathSegment
: 8 bytesTy
: 8 bytesTypeBinding
: 8 bytesTraitRef
: 8 bytesPat
: 8 bytesPatField
: 8 bytesArm
: 8 bytesBlock
: 8 bytesLocal
: 8 bytesCtor
: 8 bytesLifetime
: 8 bytesGenericParam
: 8 bytesCrate
: 8 bytesInfer
: 8 bytes