Some more refactoring

This commit is contained in:
Florian Diebold 2020-01-05 21:32:18 +01:00
parent def124e932
commit 12905e5b58
2 changed files with 16 additions and 8 deletions

View file

@ -322,3 +322,13 @@ impl InFile<SyntaxNode> {
})
}
}
impl<N: AstNode> InFile<N> {
pub fn descendants<T: AstNode>(self) -> impl Iterator<Item = InFile<T>> {
self.value.syntax().descendants().filter_map(T::cast).map(move |n| self.with_value(n))
}
pub fn syntax(&self) -> InFile<&SyntaxNode> {
self.with_value(self.value.syntax())
}
}