From 4ad37df22339ff91779782d37ab315ef0ce274eb Mon Sep 17 00:00:00 2001 From: kjeremy Date: Wed, 30 Oct 2019 16:09:16 -0400 Subject: runnables => match_ast! --- crates/ra_ide_api/src/runnables.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'crates/ra_ide_api/src') diff --git a/crates/ra_ide_api/src/runnables.rs b/crates/ra_ide_api/src/runnables.rs index 910883da7..1b5c8deea 100644 --- a/crates/ra_ide_api/src/runnables.rs +++ b/crates/ra_ide_api/src/runnables.rs @@ -4,7 +4,7 @@ use itertools::Itertools; use ra_db::SourceDatabase; use ra_syntax::{ ast::{self, AstNode, AttrsOwner, ModuleItemOwner, NameOwner}, - SyntaxNode, TextRange, + match_ast, SyntaxNode, TextRange, }; use crate::{db::RootDatabase, FileId}; @@ -29,12 +29,12 @@ pub(crate) fn runnables(db: &RootDatabase, file_id: FileId) -> Vec { } fn runnable(db: &RootDatabase, file_id: FileId, item: SyntaxNode) -> Option { - if let Some(fn_def) = ast::FnDef::cast(item.clone()) { - runnable_fn(fn_def) - } else if let Some(m) = ast::Module::cast(item) { - runnable_mod(db, file_id, m) - } else { - None + match_ast! { + match item { + ast::FnDef(it) => { runnable_fn(it) }, + ast::Module(it) => { runnable_mod(db, file_id, it) }, + _ => { None }, + } } } -- cgit v1.2.3