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 Mar 22, 2020
1 parent e8dc51e commit cd9d9e3
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 @@ -105,3 +105,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 cd9d9e3

Please sign in to comment.