Skip to content

Commit

Permalink
Remove Boxing
Browse files Browse the repository at this point in the history
  • Loading branch information
jonhoo committed May 4, 2020
1 parent d083aab commit 346858d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
rust_2018_idioms
)]
#![allow(clippy::type_complexity)]
#![feature(type_alias_impl_trait)]

const YIELD_EVERY: usize = 24;

Expand Down
10 changes: 5 additions & 5 deletions src/multiplex/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ where
{
type Error = SpawnError<NT::MakeError>;
type Response = Client<NT::Transport, Error<NT::Transport, Request>, Request>;
type Future = Pin<Box<dyn Future<Output = Result<Self::Response, Self::Error>> + Send>>;
type Future = impl Future<Output = Result<Self::Response, Self::Error>> + Send;

fn call(&mut self, target: Target) -> Self::Future {
let maker = self.t_maker.make_transport(target);
Box::pin(async move { Ok(Client::new(maker.await.map_err(SpawnError::Inner)?)) })
async move { Ok(Client::new(maker.await.map_err(SpawnError::Inner)?)) }
}

fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
Expand Down Expand Up @@ -390,7 +390,7 @@ where
{
type Response = T::Ok;
type Error = E;
type Future = Pin<Box<dyn Future<Output = Result<Self::Response, Self::Error>> + Send>>;
type Future = impl Future<Output = Result<Self::Response, Self::Error>> + Send;

fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), E>> {
Poll::Ready(ready!(self.mediator.poll_ready(cx)).map_err(|_| E::from(Error::ClientDropped)))
Expand All @@ -402,7 +402,7 @@ where
tracing::trace!("issuing request");
let req = ClientRequest { req, span, res: tx };
let r = self.mediator.try_send(req);
Box::pin(async move {
async move {
match r {
Ok(()) => match rx.await {
Ok(r) => {
Expand All @@ -413,7 +413,7 @@ where
},
Err(_) => Err(E::from(Error::TransportFull)),
}
})
}
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/pipeline/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ where
{
type Error = SpawnError<NT::MakeError>;
type Response = Client<NT::Transport, Error<NT::Transport, Request>, Request>;
type Future = Pin<Box<dyn Future<Output = Result<Self::Response, Self::Error>> + Send>>;
type Future = impl Future<Output = Result<Self::Response, Self::Error>> + Send;

fn call(&mut self, target: Target) -> Self::Future {
let maker = self.t_maker.make_transport(target);
Box::pin(async move { Ok(Client::new(maker.await.map_err(SpawnError::Inner)?)) })
async move { Ok(Client::new(maker.await.map_err(SpawnError::Inner)?)) }
}

fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
Expand Down Expand Up @@ -350,7 +350,7 @@ where
{
type Response = T::Ok;
type Error = E;
type Future = Pin<Box<dyn Future<Output = Result<Self::Response, Self::Error>> + Send>>;
type Future = impl Future<Output = Result<Self::Response, Self::Error>> + Send;

fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), E>> {
Poll::Ready(ready!(self.mediator.poll_ready(cx)).map_err(|_| E::from(Error::ClientDropped)))
Expand All @@ -362,7 +362,7 @@ where
tracing::trace!("issuing request");
let req = ClientRequest { req, span, res: tx };
let r = self.mediator.try_send(req);
Box::pin(async move {
async move {
match r {
Ok(()) => match rx.await {
Ok(r) => {
Expand All @@ -373,7 +373,7 @@ where
},
Err(_) => Err(E::from(Error::TransportFull)),
}
})
}
}
}

Expand Down

0 comments on commit 346858d

Please sign in to comment.