cleanup casts

This commit is contained in:
Aleksey Kladov 2019-07-19 18:22:00 +03:00
parent 8718a47088
commit 5c594bcb48
6 changed files with 975 additions and 850 deletions

View file

@ -61,12 +61,8 @@ impl<N: AstNode> AstPtr<N> {
self.raw
}
// FIXME: extend AstNode to do this safely
pub fn cast_checking_kind<U: AstNode>(
self,
cond: impl FnOnce(SyntaxKind) -> bool,
) -> Option<AstPtr<U>> {
if !cond(self.raw.kind()) {
pub fn cast<U: AstNode>(self) -> Option<AstPtr<U>> {
if !U::can_cast(self.raw.kind()) {
return None;
}
Some(AstPtr { raw: self.raw, _ty: PhantomData })