paralegal_flow::utils

Trait NodeExt

Source
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§

Source

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 fns 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.

Implementations on Foreign Types§

Source§

impl<'hir> NodeExt<'hir> for Node<'hir>

Source§

fn as_fn(&self, tcx: TyCtxt<'_>) -> Option<(Ident, LocalDefId, BodyId)>

Implementors§