about summary refs log tree commit diff
diff options
context:
space:
mode:
authorvarkor <github@varkor.com>2019-04-18 18:47:52 +0100
committervarkor <github@varkor.com>2019-04-20 22:03:39 +0100
commit4bbd29f2066b58d0efef6fe724807daa3d85d237 (patch)
tree091d6ea95769ae4cbef2c24c806bd29d3ea3ee47
parentc0ad4b0a96d039ef113a3ad5e422058e6f8fd2d7 (diff)
downloadrust-4bbd29f2066b58d0efef6fe724807daa3d85d237.tar.gz
rust-4bbd29f2066b58d0efef6fe724807daa3d85d237.zip
Refactor some existing methods
-rw-r--r--src/librustc/hir/map/blocks.rs18
1 files changed, 3 insertions, 15 deletions
diff --git a/src/librustc/hir/map/blocks.rs b/src/librustc/hir/map/blocks.rs
index 1114ef52bbc..f50037a746d 100644
--- a/src/librustc/hir/map/blocks.rs
+++ b/src/librustc/hir/map/blocks.rs
@@ -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> {