Skip to content

Commit d7a539f

Browse files
committed
Remove From impl, change left_and_right impl to use .or_default()
Signed-off-by: Justus Fluegel <[email protected]>
1 parent 5fe48e5 commit d7a539f

File tree

1 file changed

+1
-12
lines changed

1 file changed

+1
-12
lines changed

src/either_or_both.rs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,7 @@ impl<A, B> EitherOrBoth<A, B> {
7070
/// If `Left` return `(Some(..), None)`, if `Right` return `(None,Some(..))`, else return
7171
/// `(Some(..),Some(..))`
7272
pub fn left_and_right(self) -> (Option<A>, Option<B>) {
73-
match self.map_any(Some, Some) {
74-
EitherOrBoth::Left(l) => (l, None),
75-
EitherOrBoth::Right(r) => (None, r),
76-
EitherOrBoth::Both(l, r) => (l, r),
77-
}
73+
self.map_any(Some, Some).or_default()
7874
}
7975

8076
/// If `Left`, return `Some` with the left value. If `Right` or `Both`, return `None`.
@@ -505,10 +501,3 @@ impl<A, B> Into<Option<Either<A, B>>> for EitherOrBoth<A, B> {
505501
}
506502
}
507503
}
508-
509-
impl<A, B> From<EitherOrBoth<A, B>> for (Option<A>, Option<B>) {
510-
#[inline(always)]
511-
fn from(val: EitherOrBoth<A, B>) -> Self {
512-
val.left_and_right()
513-
}
514-
}

0 commit comments

Comments
 (0)