Skip to content

Commit 9a481d1

Browse files
committed
add: clean api to get raw_ptr type
1 parent 4e29820 commit 9a481d1

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

crates/hir/src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3190,6 +3190,14 @@ impl Type {
31903190
matches!(self.ty.kind(Interner), TyKind::Raw(..))
31913191
}
31923192

3193+
pub fn as_raw_ptr_ty(&self) -> Option<Type> {
3194+
if let TyKind::Raw(_, ty) = self.ty.kind(Interner) {
3195+
Some(self.derived(ty.clone()))
3196+
} else {
3197+
None
3198+
}
3199+
}
3200+
31933201
pub fn contains_unknown(&self) -> bool {
31943202
// FIXME: When we get rid of `ConstScalar::Unknown`, we can just look at precomputed
31953203
// `TypeFlags` in `TyData`.

0 commit comments

Comments
 (0)