feat: add is_float & is_char to hir::Type

This commit is contained in:
Swarnim Arun 2023-03-13 15:46:15 +05:30
parent 9549753352
commit fe82649e77
No known key found for this signature in database
GPG Key ID: C4DD2E124886C2D2

View File

@ -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,