mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 15:15:24 +00:00
Support if-let in scopes
This commit is contained in:
parent
c16530c988
commit
07cbb7d73d
12 changed files with 289 additions and 104 deletions
|
@ -115,6 +115,18 @@ impl<'a> Module<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> IfExpr<'a> {
|
||||
pub fn then_branch(self) -> Option<Block<'a>> {
|
||||
self.blocks().nth(0)
|
||||
}
|
||||
pub fn else_branch(self) -> Option<Block<'a>> {
|
||||
self.blocks().nth(1)
|
||||
}
|
||||
fn blocks(self) -> impl Iterator<Item=Block<'a>> {
|
||||
children(self)
|
||||
}
|
||||
}
|
||||
|
||||
fn child_opt<'a, P: AstNode<'a>, C: AstNode<'a>>(parent: P) -> Option<C> {
|
||||
children(parent).next()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue