Skip to content

Commit

Permalink
Generalize Reply impl for Box<dyn Reply> (#450)
Browse files Browse the repository at this point in the history
We had a case where we were boxing up replies, and needed them to impl `Send + Sync` to use in other code. `Box<dyn Reply + Send + Sync>` unfortunately doesn't implement `Reply`, because the impl is too specific. This generalizes the impl of `Reply` to include any `Box<T>` where `T: Reply + ?Sized`.
  • Loading branch information
mikeyhew committed Feb 19, 2020
1 parent 6c4283a commit e1d6834
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/reply.rs
Expand Up @@ -289,7 +289,7 @@ pub trait Reply: BoxedReply + Send {
*/
}

impl Reply for Box<dyn Reply> {
impl<T: Reply + ?Sized> Reply for Box<T> {
fn into_response(self) -> Response {
self.boxed_into_response(Internal)
}
Expand Down Expand Up @@ -541,7 +541,7 @@ mod sealed {

impl<T: Reply> BoxedReply for T {
fn boxed_into_response(self: Box<Self>, _: Internal) -> Response {
self.into_response()
(*self).into_response()
}
}
}
Expand Down

0 comments on commit e1d6834

Please sign in to comment.