Skip to content

Commit da47391

Browse files
authored
feat: implement Reply for Result<impl Reply, impl Reply> (#909)
1 parent e562afa commit da47391

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/reply.rs

+12-6
Original file line numberDiff line numberDiff line change
@@ -411,18 +411,24 @@ impl Reply for ::http::StatusCode {
411411
}
412412
}
413413

414-
impl<T> Reply for Result<T, ::http::Error>
414+
impl Reply for ::http::Error {
415+
#[inline]
416+
fn into_response(self) -> Response {
417+
tracing::error!("reply error: {:?}", self);
418+
StatusCode::INTERNAL_SERVER_ERROR.into_response()
419+
}
420+
}
421+
422+
impl<T, E> Reply for Result<T, E>
415423
where
416-
T: Reply + Send,
424+
T: Reply,
425+
E: Reply,
417426
{
418427
#[inline]
419428
fn into_response(self) -> Response {
420429
match self {
421430
Ok(t) => t.into_response(),
422-
Err(e) => {
423-
tracing::error!("reply error: {:?}", e);
424-
StatusCode::INTERNAL_SERVER_ERROR.into_response()
425-
}
431+
Err(e) => e.into_response(),
426432
}
427433
}
428434
}

0 commit comments

Comments
 (0)