aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/either.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/either.rs')
-rw-r--r--crates/ra_hir/src/either.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/crates/ra_hir/src/either.rs b/crates/ra_hir/src/either.rs
index 4073cc82e..71c53ebc0 100644
--- a/crates/ra_hir/src/either.rs
+++ b/crates/ra_hir/src/either.rs
@@ -25,4 +25,22 @@ impl<A, B> Either<A, B> {
25 Either::B(b) => Either::B(f2(b)), 25 Either::B(b) => Either::B(f2(b)),
26 } 26 }
27 } 27 }
28 pub fn a(self) -> Option<A> {
29 match self {
30 Either::A(it) => Some(it),
31 Either::B(_) => None,
32 }
33 }
34 pub fn b(self) -> Option<B> {
35 match self {
36 Either::A(_) => None,
37 Either::B(it) => Some(it),
38 }
39 }
40 pub fn as_ref(&self) -> Either<&A, &B> {
41 match self {
42 Either::A(it) => Either::A(it),
43 Either::B(it) => Either::B(it),
44 }
45 }
28} 46}