From 423412b5a58d863df67a711ca43d311dc5a22066 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 0b4aa3f78..ee03d8f83 100644 --- a/src/response/into_response.rs +++ b/src/response/into_response.rs @@ -109,3 +109,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(), + } + } +}