mirror of https://github.com/fafhrd91/actix-web
chore: remove Option<()> impl
This commit is contained in:
parent
e1b204bb2a
commit
a2a8edb3a5
|
@ -3,9 +3,9 @@
|
|||
## Unreleased
|
||||
|
||||
- On Windows, an error is now returned from `HttpServer::bind()` (or TLS variants) when binding to a socket that's already in use.
|
||||
- Implemented `Responder` for `Result<(), E: Into<Error>>`. Returning `Ok(())` responds with HTTP 204 No Content.
|
||||
- Update `brotli` dependency to `7`.
|
||||
- Minimum supported Rust version (MSRV) is now 1.75.
|
||||
- Implemented responder for `Option<()>` and `Result<(), E: Error> to respond with `204 No Content`
|
||||
|
||||
## 4.9.0
|
||||
|
||||
|
|
|
@ -116,17 +116,6 @@ impl<R: Responder> Responder for Option<R> {
|
|||
}
|
||||
}
|
||||
|
||||
//Note see https://github.com/actix/actix-web/issues/1108 on why Responder is not implemented for ()
|
||||
impl Responder for Option<()> {
|
||||
type Body = BoxBody;
|
||||
fn respond_to(self, _req: &HttpRequest) -> HttpResponse {
|
||||
match self {
|
||||
Some(()) => HttpResponse::NoContent().finish(),
|
||||
None => HttpResponse::NotFound().finish(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<R, E> Responder for Result<R, E>
|
||||
where
|
||||
R: Responder,
|
||||
|
@ -142,14 +131,19 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
//Note see https://github.com/actix/actix-web/issues/1108 on why Responder is not implemented for ()
|
||||
impl<E: Into<Error>> Responder for Result<(), E> {
|
||||
// Note: see https://github.com/actix/actix-web/issues/1108 for reasoning why Responder is not
|
||||
// implemented for `()`, and https://github.com/actix/actix-web/pull/3560 for discussion about this
|
||||
// impl and the decision not to include a similar one for `Option<()>`.
|
||||
impl<E> Responder for Result<(), E>
|
||||
where
|
||||
E: Into<Error>,
|
||||
{
|
||||
type Body = BoxBody;
|
||||
|
||||
fn respond_to(self, _req: &HttpRequest) -> HttpResponse {
|
||||
match self {
|
||||
Ok(()) => HttpResponse::new(StatusCode::NO_CONTENT),
|
||||
Err(e) => HttpResponse::from_error(e.into()),
|
||||
Err(err) => HttpResponse::from_error(err.into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue