diff options
Diffstat (limited to 'crates/ra_hir_ty/src/lib.rs')
-rw-r--r-- | crates/ra_hir_ty/src/lib.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/crates/ra_hir_ty/src/lib.rs b/crates/ra_hir_ty/src/lib.rs index 18f74d3b1..2677f3af2 100644 --- a/crates/ra_hir_ty/src/lib.rs +++ b/crates/ra_hir_ty/src/lib.rs | |||
@@ -680,6 +680,16 @@ impl Ty { | |||
680 | } | 680 | } |
681 | } | 681 | } |
682 | 682 | ||
683 | pub fn strip_references(&self) -> &Ty { | ||
684 | let mut t: &Ty = self; | ||
685 | |||
686 | while let Ty::Apply(ApplicationTy { ctor: TypeCtor::Ref(_mutability), parameters }) = t { | ||
687 | t = parameters.as_single(); | ||
688 | } | ||
689 | |||
690 | t | ||
691 | } | ||
692 | |||
683 | pub fn as_adt(&self) -> Option<(AdtId, &Substs)> { | 693 | pub fn as_adt(&self) -> Option<(AdtId, &Substs)> { |
684 | match self { | 694 | match self { |
685 | Ty::Apply(ApplicationTy { ctor: TypeCtor::Adt(adt_def), parameters }) => { | 695 | Ty::Apply(ApplicationTy { ctor: TypeCtor::Adt(adt_def), parameters }) => { |