Reexport, implement 'Responder' for 'Either'.

This commit is contained in:
Sergio Benitez 2021-03-29 21:58:18 -07:00
parent 0bdb6b7bc7
commit c0564fa8dc
2 changed files with 14 additions and 0 deletions

View File

@ -159,6 +159,7 @@ mod cookies;
#[doc(inline)] pub use crate::config::Config;
#[doc(inline)] pub use crate::catcher::Catcher;
#[doc(inline)] pub use crate::router::Route;
#[doc(hidden)] pub use either::Either;
pub use crate::request::Request;
pub use crate::rocket::Rocket;
pub use crate::shutdown::Shutdown;

View File

@ -297,6 +297,19 @@ impl<'r, 'o: 'r, 't: 'o, 'e: 'o, T, E> Responder<'r, 'o> for Result<T, E>
}
}
// Responds with the wrapped `Responder` in `self`, whether it is `Left` or
/// `Right`.
impl<'r, 'o: 'r, 't: 'o, 'e: 'o, T, E> Responder<'r, 'o> for crate::Either<T, E>
where T: Responder<'r, 't>, E: Responder<'r, 'e>
{
fn respond_to(self, req: &'r Request<'_>) -> response::Result<'o> {
match self {
crate::Either::Left(r) => r.respond_to(req),
crate::Either::Right(r) => r.respond_to(req),
}
}
}
/// The response generated by `Status` depends on the status code itself. The
/// table below summarizes the functionality:
///