Skip to content

Commit def4dbb

Browse files
committed
Auto merge of #14336 - swarnimarun:remove-slice, r=lnicola
internal: add `as_slice` to `hir::Type` ~`remove_slice`~ `as_slice` is same as `remove_ref` but for slices. Though there is `as_array` which I believe was named such because it also gets the length of the array, maybe. I am still shaky on the names feel free to suggest corrections.
2 parents 5780375 + cfbdf62 commit def4dbb

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

crates/hir/src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3232,6 +3232,13 @@ impl Type {
32323232
}
32333233
}
32343234

3235+
pub fn as_slice(&self) -> Option<Type> {
3236+
match &self.ty.kind(Interner) {
3237+
TyKind::Slice(ty) => Some(self.derived(ty.clone())),
3238+
_ => None,
3239+
}
3240+
}
3241+
32353242
pub fn strip_references(&self) -> Type {
32363243
self.derived(self.ty.strip_references().clone())
32373244
}

0 commit comments

Comments
 (0)