refactor(core)!: remove EitherError in favor of either::Either (#3337)

Defining our own `EitherError` type has no value now that `Either` provides the same implementation.

Related: https://github.com/libp2p/rust-libp2p/issues/3271
This commit is contained in:
Thomas Eizinger
2023-01-18 10:05:59 +11:00
committed by GitHub
parent 29a77164f1
commit f4fed3880b
17 changed files with 118 additions and 144 deletions

View File

@ -1750,12 +1750,11 @@ fn p2p_addr(peer: Option<PeerId>, addr: Multiaddr) -> Result<Multiaddr, Multiadd
mod tests {
use super::*;
use crate::test::{CallTraceBehaviour, MockBehaviour};
use either::Either;
use futures::executor::block_on;
use futures::executor::ThreadPool;
use futures::future::poll_fn;
use futures::future::Either;
use futures::{executor, future, ready};
use libp2p_core::either::EitherError;
use libp2p_core::multiaddr::multiaddr;
use libp2p_core::transport::memory::MemoryTransportError;
use libp2p_core::transport::TransportEvent;
@ -2225,13 +2224,13 @@ mod tests {
match futures::future::select(transport.select_next_some(), swarm.next())
.await
{
Either::Left((TransportEvent::Incoming { .. }, _)) => {
future::Either::Left((TransportEvent::Incoming { .. }, _)) => {
break;
}
Either::Left(_) => {
future::Either::Left(_) => {
panic!("Unexpected transport event.")
}
Either::Right((e, _)) => {
future::Either::Right((e, _)) => {
panic!("Expect swarm to not emit any event {e:?}")
}
}
@ -2633,7 +2632,7 @@ mod tests {
"/ip4/127.0.0.1/tcp/80".parse().unwrap(),
TransportError::Other(io::Error::new(
io::ErrorKind::Other,
EitherError::<_, Void>::A(EitherError::<Void, _>::B(UpgradeError::Apply(
Either::<_, Void>::Left(Either::<Void, _>::Right(UpgradeError::Apply(
MemoryTransportError::Unreachable,
))),
)),