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.
This commit is contained in:
bors 2023-03-14 09:20:58 +00:00
commit def4dbb520

View File

@ -3232,6 +3232,13 @@ pub fn remove_ref(&self) -> Option<Type> {
}
}
pub fn as_slice(&self) -> Option<Type> {
match &self.ty.kind(Interner) {
TyKind::Slice(ty) => Some(self.derived(ty.clone())),
_ => None,
}
}
pub fn strip_references(&self) -> Type {
self.derived(self.ty.strip_references().clone())
}