From c0ad4b0a96d039ef113a3ad5e422058e6f8fd2d7 Mon Sep 17 00:00:00 2001 From: varkor Date: Thu, 18 Apr 2019 18:44:55 +0100 Subject: [PATCH] Add a `header` method to `FnKind` --- src/librustc/hir/intravisit.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/librustc/hir/intravisit.rs b/src/librustc/hir/intravisit.rs index c2265eeb30d..007eaef74a7 100644 --- a/src/librustc/hir/intravisit.rs +++ b/src/librustc/hir/intravisit.rs @@ -57,6 +57,14 @@ impl<'a> FnKind<'a> { FnKind::Closure(attrs) => attrs, } } + + pub fn header(&self) -> Option { + match *self { + FnKind::ItemFn(_, _, header, _, _) => Some(header), + FnKind::Method(_, sig, _, _) => Some(sig.header), + FnKind::Closure(_) => None, + } + } } /// Specifies what nested things a visitor wants to visit. The most