Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-def/src/hir.rs')
| -rw-r--r-- | crates/hir-def/src/hir.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/crates/hir-def/src/hir.rs b/crates/hir-def/src/hir.rs index a964512beb..6aca610a93 100644 --- a/crates/hir-def/src/hir.rs +++ b/crates/hir-def/src/hir.rs @@ -55,12 +55,26 @@ impl ExprOrPatId { } } + pub fn is_expr(&self) -> bool { + match self { + Self::ExprId(_) => true, + _ => false, + } + } + pub fn as_pat(self) -> Option<PatId> { match self { Self::PatId(v) => Some(v), _ => None, } } + + pub fn is_pat(&self) -> bool { + match self { + Self::PatId(_) => true, + _ => false, + } + } } stdx::impl_from!(ExprId, PatId for ExprOrPatId); |