Skip to content

Commit

Permalink
Response: remove From<Result>, favor inlining
Browse files Browse the repository at this point in the history
  • Loading branch information
Fishrock123 committed Jun 25, 2020
1 parent d5e4e66 commit e663833
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
10 changes: 8 additions & 2 deletions src/middleware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,15 @@ impl<'a, State: Send + Sync + 'static> Next<'a, State> {
Box::pin(async move {
if let Some((current, next)) = self.next_middleware.split_first() {
self.next_middleware = next;
current.handle(req, self).await.into()
match current.handle(req, self).await {
Ok(request) => request,
Err(err) => err.into(),
}
} else {
self.endpoint.call(req).await.into()
match self.endpoint.call(req).await {
Ok(request) => request,
Err(err) => err.into(),
}
}
})
}
Expand Down
9 changes: 0 additions & 9 deletions src/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,15 +327,6 @@ impl From<Error> for Response {
}
}

impl From<crate::Result> for Response {
fn from(result: crate::Result) -> Self {
match result {
Ok(res) => res,
Err(err) => err.into(),
}
}
}

impl From<http::Response> for Response {
fn from(res: http::Response) -> Self {
Self {
Expand Down

0 comments on commit e663833

Please sign in to comment.