Skip to content

Commit 6fa525f

Browse files
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]>
2 parents 1f5f4cc + a5ab6a2 commit 6fa525f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

crates/hir/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2507,6 +2507,10 @@ impl Type {
25072507
matches!(self.ty.kind(Interner), TyKind::Ref(..))
25082508
}
25092509

2510+
pub fn is_slice(&self) -> bool {
2511+
matches!(self.ty.kind(Interner), TyKind::Slice(..))
2512+
}
2513+
25102514
pub fn is_usize(&self) -> bool {
25112515
matches!(self.ty.kind(Interner), TyKind::Scalar(Scalar::Uint(UintTy::Usize)))
25122516
}

0 commit comments

Comments
 (0)