Don't force handlers to return Results

This commit is contained in:
David Pedersen
2021-05-31 20:42:57 +02:00
parent 6f5b2708d5
commit d33be9683c
6 changed files with 26 additions and 21 deletions
+9
View File
@@ -7,6 +7,15 @@ pub trait IntoResponse<B> {
fn into_response(self) -> Result<Response<B>, Error>;
}
impl<B, T> IntoResponse<B> for Result<T, Error>
where
T: IntoResponse<B>,
{
fn into_response(self) -> Result<Response<B>, Error> {
self.and_then(IntoResponse::into_response)
}
}
impl<B> IntoResponse<B> for Response<B> {
fn into_response(self) -> Result<Response<B>, Error> {
Ok(self)