Skip to content

Commit

Permalink
Remove Boxing
Browse files Browse the repository at this point in the history
  • Loading branch information
jonhoo committed Jan 29, 2020
1 parent 325c5d8 commit 6197302
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 @@ -37,6 +37,7 @@
//! the client helper as `Client` in the protocol module you're working with (e.g.,
//! [`pipeline::Client`]), and the server helper as `Server` in the same place.
#![deny(missing_docs)]
#![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 @@ -85,11 +85,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 @@ -369,7 +369,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 @@ -384,7 +384,7 @@ where
event!(span, Level::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 @@ -396,7 +396,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 @@ -64,11 +64,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 @@ -332,7 +332,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 @@ -347,7 +347,7 @@ where
event!(span, Level::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 @@ -359,7 +359,7 @@ where
},
Err(_) => Err(E::from(Error::TransportFull)),
}
})
}
}
}

Expand Down

0 comments on commit 6197302

Please sign in to comment.