Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Refactor some existing methods
  • Loading branch information
varkor committed Apr 20, 2019
1 parent c0ad4b0 commit 4bbd29f
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions src/librustc/hir/map/blocks.rs
Expand Up @@ -175,27 +175,15 @@ impl<'a> FnLikeNode<'a> {
}

pub fn constness(self) -> ast::Constness {
match self.kind() {
FnKind::ItemFn(_, _, header, ..) => header.constness,
FnKind::Method(_, m, ..) => m.header.constness,
_ => ast::Constness::NotConst
}
self.kind().header().map_or(ast::Constness::NotConst, |header| header.constness)
}

pub fn asyncness(self) -> ast::IsAsync {
match self.kind() {
FnKind::ItemFn(_, _, header, ..) => header.asyncness,
FnKind::Method(_, m, ..) => m.header.asyncness,
_ => ast::IsAsync::NotAsync
}
self.kind().header().map_or(ast::IsAsync::NotAsync, |header| header.asyncness)
}

pub fn unsafety(self) -> ast::Unsafety {
match self.kind() {
FnKind::ItemFn(_, _, header, ..) => header.unsafety,
FnKind::Method(_, m, ..) => m.header.unsafety,
_ => ast::Unsafety::Normal
}
self.kind().header().map_or(ast::Unsafety::Normal, |header| header.unsafety)
}

pub fn kind(self) -> FnKind<'a> {
Expand Down

0 comments on commit 4bbd29f

Please sign in to comment.