diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2022-02-24 10:14:36 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-02-24 10:14:36 +0000 |
| commit | 6fa525fb80cb0487f9bb51240d8228d92b0c40da (patch) | |
| tree | 643757f43e8f23b36110d8be565871377e8b4a5b | |
| parent | 1f5f4ccfb1fe517278f5c093e55528d23d9cd1c7 (diff) | |
| parent | a5ab6a2f755d275e6218060ef87e35d571133bf9 (diff) | |
| download | rust-6fa525fb80cb0487f9bb51240d8228d92b0c40da.tar.gz rust-6fa525fb80cb0487f9bb51240d8228d92b0c40da.zip | |
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 <nerdy@peppe.rs>
| -rw-r--r-- | crates/hir/src/lib.rs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index f41e7ee4c4c..bd1e8278d51 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))) } |
