Refactor some existing methods

This commit is contained in:
varkor 2019-04-18 18:47:52 +01:00
parent c0ad4b0a96
commit 4bbd29f206

View File

@ -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> {