From fe82649e774e41f1a5e10d20342fc9a9550f91de Mon Sep 17 00:00:00 2001 From: Swarnim Arun Date: Mon, 13 Mar 2023 15:46:15 +0530 Subject: [PATCH] feat: add `is_float` & `is_char` to `hir::Type` --- crates/hir/src/lib.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index 25c07a2fbd3..6d0083c0711 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -3210,6 +3210,14 @@ impl Type { matches!(self.ty.kind(Interner), TyKind::Scalar(Scalar::Uint(UintTy::Usize))) } + pub fn is_float(&self) -> bool { + matches!(self.ty.kind(Interner), TyKind::Scalar(Scalar::Float(_))) + } + + pub fn is_char(&self) -> bool { + matches!(self.ty.kind(Interner), TyKind::Scalar(Scalar::Char)) + } + pub fn is_int_or_uint(&self) -> bool { match self.ty.kind(Interner) { TyKind::Scalar(Scalar::Int(_) | Scalar::Uint(_)) => true,