diff options
Diffstat (limited to 'crates/ra_hir_ty/src/lib.rs')
-rw-r--r-- | crates/ra_hir_ty/src/lib.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/crates/ra_hir_ty/src/lib.rs b/crates/ra_hir_ty/src/lib.rs index 13c5e6c6b..15356ab37 100644 --- a/crates/ra_hir_ty/src/lib.rs +++ b/crates/ra_hir_ty/src/lib.rs | |||
@@ -661,6 +661,17 @@ impl Ty { | |||
661 | } | 661 | } |
662 | } | 662 | } |
663 | 663 | ||
664 | /// If this is a `dyn Trait` type, this returns the `Trait` part. | ||
665 | pub fn dyn_trait_ref(&self) -> Option<&TraitRef> { | ||
666 | match self { | ||
667 | Ty::Dyn(bounds) => bounds.get(0).and_then(|b| match b { | ||
668 | GenericPredicate::Implemented(trait_ref) => Some(trait_ref), | ||
669 | _ => None, | ||
670 | }), | ||
671 | _ => None, | ||
672 | } | ||
673 | } | ||
674 | |||
664 | fn builtin_deref(&self) -> Option<Ty> { | 675 | fn builtin_deref(&self) -> Option<Ty> { |
665 | match self { | 676 | match self { |
666 | Ty::Apply(a_ty) => match a_ty.ctor { | 677 | Ty::Apply(a_ty) => match a_ty.ctor { |