pub trait NodeExt<'hir> {
// Required method
fn as_fn(&self, tcx: TyCtxt<'_>) -> Option<(Ident, LocalDefId, BodyId)>;
}
Expand description
Extension trait for [hir::Node
]. This lets up implement methods on
[hir::Node
]. Self
should only ever be instantiated as [hir::Node
].
Required Methods§
Sourcefn as_fn(&self, tcx: TyCtxt<'_>) -> Option<(Ident, LocalDefId, BodyId)>
fn as_fn(&self, tcx: TyCtxt<'_>) -> Option<(Ident, LocalDefId, BodyId)>
Try and unwrap this node
as some sort of function.
HIR has two different kinds of items that are types of function,
one is top-level fn
s the other is an impl
item of function type.
This function lets you extract common information from either. Returns
None
if the node is not of a function-like type.