Skip to content

Commit

Permalink
Implement IntoResponse for Result
Browse files Browse the repository at this point in the history
  • Loading branch information
Licenser committed Apr 20, 2020
1 parent 2003a99 commit 423412b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/response/into_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,16 @@ impl<R: IntoResponse> IntoResponse for WithStatus<R> {
self.inner.into_response().set_status(self.status)
}
}

impl<T, E> IntoResponse for Result<T, E>
where
T: IntoResponse,
E: IntoResponse,
{
fn into_response(self) -> Response {
match self {
Ok(t) => t.into_response(),
Err(e) => e.into_response(),
}
}
}

0 comments on commit 423412b

Please sign in to comment.