1
0
mirror of https://github.com/actix/actix-extras.git synced 2025-06-25 18:09:22 +02:00

handler info

This commit is contained in:
Nikolay Kim
2017-12-01 21:29:22 -08:00
parent 186726fbad
commit f0c346f18c
3 changed files with 105 additions and 6 deletions

View File

@ -67,6 +67,7 @@ impl Reply {
}
}
#[cfg(not(actix_nightly))]
impl<T: Into<HttpResponse>> From<T> for Reply
{
fn from(item: T) -> Self {
@ -74,6 +75,24 @@ impl<T: Into<HttpResponse>> From<T> for Reply
}
}
#[cfg(actix_nightly)]
default impl<T: Into<HttpResponse>> From<T> for Reply
{
fn from(item: T) -> Self {
Reply(ReplyItem::Message(item.into()))
}
}
#[cfg(actix_nightly)]
default impl<T: Into<HttpResponse>, E: Into<Error>> From<StdResult<T, E>> for Reply {
fn from(res: StdResult<T, E>) -> Self {
match res {
Ok(val) => val.into().into(),
Err(err) => err.into().into(),
}
}
}
impl<E: Into<Error>> From<StdResult<Reply, E>> for Reply {
fn from(res: StdResult<Reply, E>) -> Self {
match res {