Repository: rust-itertools/itertools (language: rust)

Issue:
impl a From instead of an Into
https://github.com/rust-itertools/itertools/blob/5a5731c03990449ff212b69a91e310e93500ebe3/src/either_or_both.rs#L503-L511




Discussion / hints:
It originated in #740 (`From` should be prefered to `Into` implementation as the first gives the second but it's not true the other way) where I said https://github.com/rust-itertools/itertools/pull/740#discussion_r1444264148

> I don't see a point of not doing it so I suggest you convert it to a `From` implementation in a separate commit.
> 
> EDIT: After searching, it originated in #327 and nobody said it should not be `From` instead.

In #327, there is

> A fallible method of converting `EitherOrBoth` into an `Either` would be very useful providing exclusive (not including Both variant) methods. Converting should probably wait for https://github.com/rust-lang/rust/issues/33417.

So I guess the question is: Instead of `Into<Option<_>>`, do we want a `TryFrom` or a `From` implementation?
I would vote for `From` (better than `Into`, no breaking change) over `TryFrom` (breaking change, what kind of error?).

Fix patch:
diff --git a/src/either_or_both.rs b/src/either_or_both.rs
index d13763441..b7a7fc141 100644
--- a/src/either_or_both.rs
+++ b/src/either_or_both.rs
@@ -494,10 +494,9 @@ impl<T> EitherOrBoth<T, T> {
     }
 }
 
-#[allow(clippy::from_over_into)]
-impl<A, B> Into<Option<Either<A, B>>> for EitherOrBoth<A, B> {
-    fn into(self) -> Option<Either<A, B>> {
-        match self {
+impl<A, B> From<EitherOrBoth<A, B>> for Option<Either<A, B>> {
+    fn from(value: EitherOrBoth<A, B>) -> Self {
+        match value {
             Left(l) => Some(Either::Left(l)),
             Right(r) => Some(Either::Right(r)),
             Both(..) => None,


Test patch: