diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-06-10 23:26:50 +0100 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-06-10 23:26:50 +0100 |
commit | 1c867b4e67126350579d6d598efeb6c03b503ddc (patch) | |
tree | 5e0d18e023a095c64a02f1c44c4a82245c89beeb /crates/ra_hir/src/either.rs | |
parent | 75e6c03883c4533b1134c806d166b72200b4837d (diff) | |
parent | 156b7ee84210583fa2fdc7fb8ae1dccafdf80830 (diff) |
Merge #1390
1390: use single version of either in hir r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/either.rs')
-rw-r--r-- | crates/ra_hir/src/either.rs | 18 |
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 | } |