Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir/src/lib.rs')
| -rw-r--r-- | crates/hir/src/lib.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index 6306ae534d..8d5dbd28ac 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -1685,6 +1685,26 @@ impl BuiltinType { pub fn name(self) -> Name { self.inner.as_name() } + + pub fn is_int(&self) -> bool { + matches!(self.inner, hir_def::builtin_type::BuiltinType::Int(_)) + } + + pub fn is_uint(&self) -> bool { + matches!(self.inner, hir_def::builtin_type::BuiltinType::Uint(_)) + } + + pub fn is_float(&self) -> bool { + matches!(self.inner, hir_def::builtin_type::BuiltinType::Float(_)) + } + + pub fn is_char(&self) -> bool { + matches!(self.inner, hir_def::builtin_type::BuiltinType::Char) + } + + pub fn is_str(&self) -> bool { + matches!(self.inner, hir_def::builtin_type::BuiltinType::Str) + } } #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] @@ -2573,6 +2593,10 @@ impl Type { matches!(&self.ty.kind(Interner), TyKind::FnDef(..) | TyKind::Function { .. }) } + pub fn is_array(&self) -> bool { + matches!(&self.ty.kind(Interner), TyKind::Array(..)) + } + pub fn is_packed(&self, db: &dyn HirDatabase) -> bool { let adt_id = match *self.ty.kind(Interner) { TyKind::Adt(hir_ty::AdtId(adt_id), ..) => adt_id, |