Auto merge of #14334 - swarnimarun:is-float-char, r=lnicola

feat: add `is_float` & `is_char` to `hir::Type`

Some useful functions we didn't have on `Type` (were present on `BuiltinType`).

Also, I am considering exposing `TyKind` with `get_kind`, let me know if that's a better idea than implementing these API extensions incrementally.
This commit is contained in:
bors 2023-03-14 06:56:46 +00:00
commit 057857ec23

View File

@ -3210,6 +3210,14 @@ pub fn is_usize(&self) -> bool {
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,