diff options
author | Aleksey Kladov <[email protected]> | 2018-08-27 10:22:09 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-08-27 10:22:09 +0100 |
commit | 07cbb7d73deed8dac3eecdbdc7e1eaf6938a6cd6 (patch) | |
tree | 4a1fa22fa8c908f0c3c9489a98aa2479f05def59 /crates/libsyntax2/src/ast/mod.rs | |
parent | c16530c988e817c5596fa38ebe9e12a302886a8f (diff) |
Support if-let in scopes
Diffstat (limited to 'crates/libsyntax2/src/ast/mod.rs')
-rw-r--r-- | crates/libsyntax2/src/ast/mod.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/crates/libsyntax2/src/ast/mod.rs b/crates/libsyntax2/src/ast/mod.rs index 6217c5b74..2ebee6a4f 100644 --- a/crates/libsyntax2/src/ast/mod.rs +++ b/crates/libsyntax2/src/ast/mod.rs | |||
@@ -115,6 +115,18 @@ impl<'a> Module<'a> { | |||
115 | } | 115 | } |
116 | } | 116 | } |
117 | 117 | ||
118 | impl<'a> IfExpr<'a> { | ||
119 | pub fn then_branch(self) -> Option<Block<'a>> { | ||
120 | self.blocks().nth(0) | ||
121 | } | ||
122 | pub fn else_branch(self) -> Option<Block<'a>> { | ||
123 | self.blocks().nth(1) | ||
124 | } | ||
125 | fn blocks(self) -> impl Iterator<Item=Block<'a>> { | ||
126 | children(self) | ||
127 | } | ||
128 | } | ||
129 | |||
118 | fn child_opt<'a, P: AstNode<'a>, C: AstNode<'a>>(parent: P) -> Option<C> { | 130 | fn child_opt<'a, P: AstNode<'a>, C: AstNode<'a>>(parent: P) -> Option<C> { |
119 | children(parent).next() | 131 | children(parent).next() |
120 | } | 132 | } |