diff --git a/actix-service/CHANGES.md b/actix-service/CHANGES.md index cc9dd9ef..afd194f5 100644 --- a/actix-service/CHANGES.md +++ b/actix-service/CHANGES.md @@ -2,6 +2,9 @@ ## [0.1.6] - 2019-01-xx +### Changed + +* Use `FnMut` instead of `Fn` for .apply() and .map() combinators and `FnService` type ## [0.1.5] - 2019-01-13 diff --git a/actix-service/src/apply.rs b/actix-service/src/apply.rs index e6624057..89d6559f 100644 --- a/actix-service/src/apply.rs +++ b/actix-service/src/apply.rs @@ -78,7 +78,7 @@ where impl ApplyNewService where T: NewService, - F: Fn(In, &mut T::Service) -> Out, + F: FnMut(In, &mut T::Service) -> Out, Out: IntoFuture, Out::Error: From, { @@ -95,7 +95,7 @@ where impl Clone for ApplyNewService where T: NewService + Clone, - F: Fn(In, &mut T::Service) -> Out + Clone, + F: FnMut(In, &mut T::Service) -> Out + Clone, Out: IntoFuture, { fn clone(&self) -> Self { @@ -110,7 +110,7 @@ where impl NewService for ApplyNewService where T: NewService, - F: Fn(In, &mut T::Service) -> Out + Clone, + F: FnMut(In, &mut T::Service) -> Out + Clone, Out: IntoFuture, Out::Error: From, { @@ -129,7 +129,7 @@ where pub struct ApplyNewServiceFuture where T: NewService, - F: Fn(In, &mut T::Service) -> Out, + F: FnMut(In, &mut T::Service) -> Out, Out: IntoFuture, { fut: T::Future, @@ -140,7 +140,7 @@ where impl ApplyNewServiceFuture where T: NewService, - F: Fn(In, &mut T::Service) -> Out, + F: FnMut(In, &mut T::Service) -> Out, Out: IntoFuture, { fn new(fut: T::Future, f: F) -> Self { @@ -155,7 +155,7 @@ where impl Future for ApplyNewServiceFuture where T: NewService, - F: Fn(In, &mut T::Service) -> Out, + F: FnMut(In, &mut T::Service) -> Out, Out: IntoFuture, Out::Error: From, { diff --git a/actix-service/src/lib.rs b/actix-service/src/lib.rs index 1e033273..0d2e05d5 100644 --- a/actix-service/src/lib.rs +++ b/actix-service/src/lib.rs @@ -128,7 +128,7 @@ pub trait ServiceExt: Service { fn map(self, f: F) -> Map where Self: Sized, - F: Fn(Self::Response) -> R, + F: FnMut(Self::Response) -> R, { Map::new(self, f) } @@ -245,7 +245,7 @@ pub trait NewService { fn map(self, f: F) -> MapNewService where Self: Sized, - F: Fn(Self::Response) -> R, + F: FnMut(Self::Response) -> R, { MapNewService::new(self, f) } diff --git a/actix-service/src/map.rs b/actix-service/src/map.rs index d3fb3c06..ac255ff1 100644 --- a/actix-service/src/map.rs +++ b/actix-service/src/map.rs @@ -18,7 +18,7 @@ impl Map { pub fn new(service: A, f: F) -> Self where A: Service, - F: Fn(A::Response) -> Response, + F: FnMut(A::Response) -> Response, { Self { service, @@ -45,7 +45,7 @@ where impl Service for Map where A: Service, - F: Fn(A::Response) -> Response + Clone, + F: FnMut(A::Response) -> Response + Clone, { type Response = Response; type Error = A::Error; @@ -63,7 +63,7 @@ where pub struct MapFuture where A: Service, - F: Fn(A::Response) -> Response, + F: FnMut(A::Response) -> Response, { f: F, fut: A::Future, @@ -72,7 +72,7 @@ where impl MapFuture where A: Service, - F: Fn(A::Response) -> Response, + F: FnMut(A::Response) -> Response, { fn new(fut: A::Future, f: F) -> Self { MapFuture { f, fut } @@ -82,7 +82,7 @@ where impl Future for MapFuture where A: Service, - F: Fn(A::Response) -> Response, + F: FnMut(A::Response) -> Response, { type Item = Response; type Error = A::Error; @@ -107,7 +107,7 @@ impl MapNewService { pub fn new(a: A, f: F) -> Self where A: NewService, - F: Fn(A::Response) -> Response, + F: FnMut(A::Response) -> Response, { Self { a, @@ -134,7 +134,7 @@ where impl NewService for MapNewService where A: NewService, - F: Fn(A::Response) -> Response + Clone, + F: FnMut(A::Response) -> Response + Clone, { type Response = Response; type Error = A::Error; @@ -151,7 +151,7 @@ where pub struct MapNewServiceFuture where A: NewService, - F: Fn(A::Response) -> Response, + F: FnMut(A::Response) -> Response, { fut: A::Future, f: Option, @@ -160,7 +160,7 @@ where impl MapNewServiceFuture where A: NewService, - F: Fn(A::Response) -> Response, + F: FnMut(A::Response) -> Response, { fn new(fut: A::Future, f: F) -> Self { MapNewServiceFuture { f: Some(f), fut } @@ -170,7 +170,7 @@ where impl Future for MapNewServiceFuture where A: NewService, - F: Fn(A::Response) -> Response, + F: FnMut(A::Response) -> Response, { type Item = Map; type Error = A::InitError;