Skip to content

Commit

Permalink
Remove From impl, change left_and_right impl to use .or_default()
Browse files Browse the repository at this point in the history
Signed-off-by: Justus Fluegel <[email protected]>
  • Loading branch information
JustusFluegel committed Jul 27, 2023
1 parent 5fe48e5 commit d7a539f
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions src/either_or_both.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,7 @@ impl<A, B> EitherOrBoth<A, B> {
/// If `Left` return `(Some(..), None)`, if `Right` return `(None,Some(..))`, else return
/// `(Some(..),Some(..))`
pub fn left_and_right(self) -> (Option<A>, Option<B>) {
match self.map_any(Some, Some) {
EitherOrBoth::Left(l) => (l, None),
EitherOrBoth::Right(r) => (None, r),
EitherOrBoth::Both(l, r) => (l, r),
}
self.map_any(Some, Some).or_default()
}

/// If `Left`, return `Some` with the left value. If `Right` or `Both`, return `None`.
Expand Down Expand Up @@ -505,10 +501,3 @@ impl<A, B> Into<Option<Either<A, B>>> for EitherOrBoth<A, B> {
}
}
}

impl<A, B> From<EitherOrBoth<A, B>> for (Option<A>, Option<B>) {
#[inline(always)]
fn from(val: EitherOrBoth<A, B>) -> Self {
val.left_and_right()
}
}

0 comments on commit d7a539f

Please sign in to comment.