Implement `ResponseError` for `Infallible`

This commit is contained in:
SabrinaJewson 2022-05-30 18:39:04 +01:00
parent 6a5b370206
commit 7b8f7ae4f3
No known key found for this signature in database
GPG Key ID: 3D5438FFA5F05564
2 changed files with 10 additions and 6 deletions

View File

@ -51,12 +51,6 @@ impl StdError for Error {
}
}
impl From<std::convert::Infallible> for Error {
fn from(val: std::convert::Infallible) -> Self {
match val {}
}
}
/// `Error` for any error that implements `ResponseError`
impl<T: ResponseError + 'static> From<T> for Error {
fn from(err: T) -> Error {

View File

@ -1,6 +1,7 @@
//! `ResponseError` trait and foreign impls.
use std::{
convert::Infallible,
error::Error as StdError,
fmt,
io::{self, Write as _},
@ -54,6 +55,15 @@ downcast_dyn!(ResponseError);
impl ResponseError for Box<dyn StdError + 'static> {}
impl ResponseError for Infallible {
fn status_code(&self) -> StatusCode {
match *self {}
}
fn error_response(&self) -> HttpResponse<BoxBody> {
match *self {}
}
}
#[cfg(feature = "openssl")]
impl ResponseError for actix_tls::accept::openssl::reexports::Error {}