diff options
Diffstat (limited to 'crates/ra_hir_ty/src/lib.rs')
-rw-r--r-- | crates/ra_hir_ty/src/lib.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/crates/ra_hir_ty/src/lib.rs b/crates/ra_hir_ty/src/lib.rs index 279c06d65..a8ef32ec5 100644 --- a/crates/ra_hir_ty/src/lib.rs +++ b/crates/ra_hir_ty/src/lib.rs | |||
@@ -487,6 +487,18 @@ impl<T> Binders<T> { | |||
487 | pub fn new(num_binders: usize, value: T) -> Self { | 487 | pub fn new(num_binders: usize, value: T) -> Self { |
488 | Self { num_binders, value } | 488 | Self { num_binders, value } |
489 | } | 489 | } |
490 | |||
491 | pub fn as_ref(&self) -> Binders<&T> { | ||
492 | Binders { num_binders: self.num_binders, value: &self.value } | ||
493 | } | ||
494 | |||
495 | pub fn map<U>(self, f: impl FnOnce(T) -> U) -> Binders<U> { | ||
496 | Binders { num_binders: self.num_binders, value: f(self.value) } | ||
497 | } | ||
498 | |||
499 | pub fn filter_map<U>(self, f: impl FnOnce(T) -> Option<U>) -> Option<Binders<U>> { | ||
500 | Some(Binders { num_binders: self.num_binders, value: f(self.value)? }) | ||
501 | } | ||
490 | } | 502 | } |
491 | 503 | ||
492 | impl<T: Clone> Binders<&T> { | 504 | impl<T: Clone> Binders<&T> { |