From cd9d9e3f5ec2a35fa4b6da925d85b717f3ab45a5 Mon Sep 17 00:00:00 2001 From: "Heinz N. Gies" Date: Wed, 19 Feb 2020 15:36:21 +0100 Subject: [PATCH] Implement IntoResponse for Result --- src/response/into_response.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/response/into_response.rs b/src/response/into_response.rs index 35f734867..6763d8853 100644 --- a/src/response/into_response.rs +++ b/src/response/into_response.rs @@ -105,3 +105,16 @@ impl IntoResponse for WithStatus { self.inner.into_response().set_status(self.status) } } + +impl IntoResponse for Result +where + T: IntoResponse, + E: IntoResponse, +{ + fn into_response(self) -> Response { + match self { + Ok(t) => t.into_response(), + Err(e) => e.into_response(), + } + } +}