diff --git a/actix-service/src/and_then_apply.rs b/actix-service/src/and_then_apply.rs
index 125cb896..26db80f5 100644
--- a/actix-service/src/and_then_apply.rs
+++ b/actix-service/src/and_then_apply.rs
@@ -6,7 +6,14 @@ use super::{IntoNewService, IntoService, NewService, Service};
use crate::cell::Cell;
/// `Apply` service combinator
-pub struct AndThenApply {
+pub struct AndThenApply
+where
+ A: Service,
+ B: Service,
+ F: FnMut(A::Response, &mut B) -> Out,
+ Out: IntoFuture,
+ Out::Error: Into,
+{
a: A,
b: Cell,
f: Cell,
@@ -19,7 +26,7 @@ where
B: Service,
F: FnMut(A::Response, &mut B) -> Out,
Out: IntoFuture,
- Out::Error: From,
+ Out::Error: Into,
{
/// Create new `Apply` combinator
pub fn new, B1: IntoService>(a: A1, b: B1, f: F) -> Self {
@@ -34,7 +41,11 @@ where
impl Clone for AndThenApply
where
- A: Clone,
+ A: Service + Clone,
+ B: Service,
+ F: FnMut(A::Response, &mut B) -> Out,
+ Out: IntoFuture,
+ Out::Error: Into,
{
fn clone(&self) -> Self {
AndThenApply {
@@ -52,14 +63,14 @@ where
B: Service,
F: FnMut(A::Response, &mut B) -> Out,
Out: IntoFuture,
- Out::Error: From,
+ Out::Error: Into,
{
type Response = Out::Item;
- type Error = Out::Error;
+ type Error = A::Error;
type Future = AndThenApplyFuture;
fn poll_ready(&mut self) -> Poll<(), Self::Error> {
- try_ready!(self.a.poll_ready().map_err(|e| e.into()));
+ try_ready!(self.a.poll_ready());
self.b.get_mut().poll_ready().map_err(|e| e.into())
}
@@ -80,7 +91,7 @@ where
B: Service,
F: FnMut(A::Response, &mut B) -> Out,
Out: IntoFuture,
- Out::Error: From,
+ Out::Error: Into,
{
b: Cell,
f: Cell,
@@ -95,14 +106,14 @@ where
B: Service,
F: FnMut(A::Response, &mut B) -> Out,
Out: IntoFuture,
- Out::Error: From,
+ Out::Error: Into,
{
type Item = Out::Item;
- type Error = Out::Error;
+ type Error = A::Error;
fn poll(&mut self) -> Poll {
if let Some(ref mut fut) = self.fut_b {
- return fut.poll();
+ return fut.poll().map_err(|e| e.into());
}
match self.fut_a.as_mut().expect("Bug in actix-service").poll() {
@@ -132,7 +143,7 @@ where
B: NewService,
F: FnMut(A::Response, &mut B::Service) -> Out,
Out: IntoFuture,
- Out::Error: From,
+ Out::Error: Into,
{
/// Create new `ApplyNewService` new service instance
pub fn new, B1: IntoNewService>(
@@ -171,10 +182,10 @@ where
B: NewService,
F: FnMut(A::Response, &mut B::Service) -> Out,
Out: IntoFuture,
- Out::Error: From,
+ Out::Error: Into,
{
type Response = Out::Item;
- type Error = Out::Error;
+ type Error = A::Error;
type InitError = A::InitError;
type Service = AndThenApply;
@@ -197,7 +208,7 @@ where
B: NewService,
F: FnMut(A::Response, &mut B::Service) -> Out,
Out: IntoFuture,
- Out::Error: From,
+ Out::Error: Into,
{
fut_b: B::Future,
fut_a: A::Future,
@@ -212,7 +223,7 @@ where
B: NewService,
F: FnMut(A::Response, &mut B::Service) -> Out,
Out: IntoFuture,
- Out::Error: From,
+ Out::Error: Into,
{
type Item = AndThenApply;
type Error = A::InitError;
diff --git a/actix-service/src/lib.rs b/actix-service/src/lib.rs
index 38fae4d7..4de01abb 100644
--- a/actix-service/src/lib.rs
+++ b/actix-service/src/lib.rs
@@ -71,7 +71,7 @@ pub trait ServiceExt: Service {
I: IntoService,
F: FnMut(Self::Response, &mut B) -> Out,
Out: IntoFuture,
- Out::Error: From,
+ Out::Error: Into,
{
AndThenApply::new(self, service, f)
}
@@ -197,7 +197,7 @@ pub trait NewService {
I: IntoNewService,
F: FnMut(Self::Response, &mut B::Service) -> Out,
Out: IntoFuture,
- Out::Error: From,
+ Out::Error: Into,
{
AndThenApplyNewService::new(self, service, f)
}