Unnamed repository; edit this file 'description' to name the repository.
Merge #11545
11545: add `is_slice` method to `hir::Type` r=flodiebold a=nerdypepper would like to have this on `hir::Type` for a small project i am working on, unless there is another way to check if `hir::Type` is a slice primitive? Co-authored-by: Akshay <[email protected]>
bors[bot] 2022-02-24
parent 1f5f4cc · parent a5ab6a2 · commit 6fa525f
-rw-r--r--crates/hir/src/lib.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs
index f41e7ee4c4..bd1e8278d5 100644
--- a/crates/hir/src/lib.rs
+++ b/crates/hir/src/lib.rs
@@ -2507,6 +2507,10 @@ impl Type {
matches!(self.ty.kind(Interner), TyKind::Ref(..))
}
+ pub fn is_slice(&self) -> bool {
+ matches!(self.ty.kind(Interner), TyKind::Slice(..))
+ }
+
pub fn is_usize(&self) -> bool {
matches!(self.ty.kind(Interner), TyKind::Scalar(Scalar::Uint(UintTy::Usize)))
}