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 Jul 7, 2020
1 parent 368855d commit 9bf7c09
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 @@ -51,9 +51,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 @@ -388,15 +388,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 9bf7c09

Please sign in to comment.