From 7ad55e976c3f88e92075379c8a4c1f413665b458 Mon Sep 17 00:00:00 2001 From: kjeremy Date: Wed, 30 Oct 2019 14:38:45 -0400 Subject: Document match_ast! --- crates/ra_syntax/src/lib.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'crates/ra_syntax') diff --git a/crates/ra_syntax/src/lib.rs b/crates/ra_syntax/src/lib.rs index c315ba552..5dcb6a95a 100644 --- a/crates/ra_syntax/src/lib.rs +++ b/crates/ra_syntax/src/lib.rs @@ -160,6 +160,20 @@ impl SourceFile { } } +/// Matches a `SyntaxNode` against an `ast` type. +/// +/// # Example: +/// +/// ```ignore +/// match_ast! { +/// match node { +/// ast::CallExpr(it) => { ... }, +/// ast::MethodCallExpr(it) => { ... }, +/// ast::MacroCall(it) => { ... }, +/// _ => None, +/// } +/// } +/// ``` #[macro_export] macro_rules! match_ast { (match $node:ident { -- cgit v1.2.3