Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-ty/src/next_solver/ty.rs')
| -rw-r--r-- | crates/hir-ty/src/next_solver/ty.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/crates/hir-ty/src/next_solver/ty.rs b/crates/hir-ty/src/next_solver/ty.rs index 030ba37015..66a24d3949 100644 --- a/crates/hir-ty/src/next_solver/ty.rs +++ b/crates/hir-ty/src/next_solver/ty.rs @@ -383,6 +383,11 @@ impl<'db> Ty<'db> { matches!(self.kind(), TyKind::Bool) } + #[inline] + pub fn is_char(self) -> bool { + matches!(self.kind(), TyKind::Char) + } + /// A scalar type is one that denotes an atomic datum, with no sub-components. /// (A RawPtr is scalar because it represents a non-managed pointer, so its /// contents are abstract to rustc.) @@ -423,6 +428,11 @@ impl<'db> Ty<'db> { } #[inline] + pub fn is_u8(self) -> bool { + matches!(self.kind(), TyKind::Uint(UintTy::U8)) + } + + #[inline] pub fn is_raw_ptr(self) -> bool { matches!(self.kind(), TyKind::RawPtr(..)) } @@ -457,6 +467,14 @@ impl<'db> Ty<'db> { } #[inline] + pub fn as_slice(self) -> Option<Ty<'db>> { + match self.kind() { + TyKind::Slice(ty) => Some(ty), + _ => None, + } + } + + #[inline] pub fn ty_vid(self) -> Option<TyVid> { match self.kind() { TyKind::Infer(rustc_type_ir::TyVar(vid)) => Some(vid), |