mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-04 17:40:50 +00:00
cleanup casts
This commit is contained in:
parent
8718a47088
commit
5c594bcb48
6 changed files with 975 additions and 850 deletions
|
@ -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 })
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue