mirror of
https://github.com/fafhrd91/actix-net
synced 2024-11-24 05:52:59 +01:00
use FnMut instead of Fn
This commit is contained in:
parent
2c8e7c4ae4
commit
278176fca5
@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
## [0.1.6] - 2019-01-xx
|
## [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
|
## [0.1.5] - 2019-01-13
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ where
|
|||||||
impl<T, F, In, Out, Request> ApplyNewService<T, F, In, Out, Request>
|
impl<T, F, In, Out, Request> ApplyNewService<T, F, In, Out, Request>
|
||||||
where
|
where
|
||||||
T: NewService<Request>,
|
T: NewService<Request>,
|
||||||
F: Fn(In, &mut T::Service) -> Out,
|
F: FnMut(In, &mut T::Service) -> Out,
|
||||||
Out: IntoFuture,
|
Out: IntoFuture,
|
||||||
Out::Error: From<T::Error>,
|
Out::Error: From<T::Error>,
|
||||||
{
|
{
|
||||||
@ -95,7 +95,7 @@ where
|
|||||||
impl<T, F, In, Out, Request> Clone for ApplyNewService<T, F, In, Out, Request>
|
impl<T, F, In, Out, Request> Clone for ApplyNewService<T, F, In, Out, Request>
|
||||||
where
|
where
|
||||||
T: NewService<Request> + Clone,
|
T: NewService<Request> + Clone,
|
||||||
F: Fn(In, &mut T::Service) -> Out + Clone,
|
F: FnMut(In, &mut T::Service) -> Out + Clone,
|
||||||
Out: IntoFuture,
|
Out: IntoFuture,
|
||||||
{
|
{
|
||||||
fn clone(&self) -> Self {
|
fn clone(&self) -> Self {
|
||||||
@ -110,7 +110,7 @@ where
|
|||||||
impl<T, F, In, Out, Request> NewService<In> for ApplyNewService<T, F, In, Out, Request>
|
impl<T, F, In, Out, Request> NewService<In> for ApplyNewService<T, F, In, Out, Request>
|
||||||
where
|
where
|
||||||
T: NewService<Request>,
|
T: NewService<Request>,
|
||||||
F: Fn(In, &mut T::Service) -> Out + Clone,
|
F: FnMut(In, &mut T::Service) -> Out + Clone,
|
||||||
Out: IntoFuture,
|
Out: IntoFuture,
|
||||||
Out::Error: From<T::Error>,
|
Out::Error: From<T::Error>,
|
||||||
{
|
{
|
||||||
@ -129,7 +129,7 @@ where
|
|||||||
pub struct ApplyNewServiceFuture<T, F, In, Out, Request>
|
pub struct ApplyNewServiceFuture<T, F, In, Out, Request>
|
||||||
where
|
where
|
||||||
T: NewService<Request>,
|
T: NewService<Request>,
|
||||||
F: Fn(In, &mut T::Service) -> Out,
|
F: FnMut(In, &mut T::Service) -> Out,
|
||||||
Out: IntoFuture,
|
Out: IntoFuture,
|
||||||
{
|
{
|
||||||
fut: T::Future,
|
fut: T::Future,
|
||||||
@ -140,7 +140,7 @@ where
|
|||||||
impl<T, F, In, Out, Request> ApplyNewServiceFuture<T, F, In, Out, Request>
|
impl<T, F, In, Out, Request> ApplyNewServiceFuture<T, F, In, Out, Request>
|
||||||
where
|
where
|
||||||
T: NewService<Request>,
|
T: NewService<Request>,
|
||||||
F: Fn(In, &mut T::Service) -> Out,
|
F: FnMut(In, &mut T::Service) -> Out,
|
||||||
Out: IntoFuture,
|
Out: IntoFuture,
|
||||||
{
|
{
|
||||||
fn new(fut: T::Future, f: F) -> Self {
|
fn new(fut: T::Future, f: F) -> Self {
|
||||||
@ -155,7 +155,7 @@ where
|
|||||||
impl<T, F, In, Out, Request> Future for ApplyNewServiceFuture<T, F, In, Out, Request>
|
impl<T, F, In, Out, Request> Future for ApplyNewServiceFuture<T, F, In, Out, Request>
|
||||||
where
|
where
|
||||||
T: NewService<Request>,
|
T: NewService<Request>,
|
||||||
F: Fn(In, &mut T::Service) -> Out,
|
F: FnMut(In, &mut T::Service) -> Out,
|
||||||
Out: IntoFuture,
|
Out: IntoFuture,
|
||||||
Out::Error: From<T::Error>,
|
Out::Error: From<T::Error>,
|
||||||
{
|
{
|
||||||
|
@ -128,7 +128,7 @@ pub trait ServiceExt<Request>: Service<Request> {
|
|||||||
fn map<F, R>(self, f: F) -> Map<Self, F, R>
|
fn map<F, R>(self, f: F) -> Map<Self, F, R>
|
||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
F: Fn(Self::Response) -> R,
|
F: FnMut(Self::Response) -> R,
|
||||||
{
|
{
|
||||||
Map::new(self, f)
|
Map::new(self, f)
|
||||||
}
|
}
|
||||||
@ -245,7 +245,7 @@ pub trait NewService<Request> {
|
|||||||
fn map<F, R>(self, f: F) -> MapNewService<Self, F, R>
|
fn map<F, R>(self, f: F) -> MapNewService<Self, F, R>
|
||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
F: Fn(Self::Response) -> R,
|
F: FnMut(Self::Response) -> R,
|
||||||
{
|
{
|
||||||
MapNewService::new(self, f)
|
MapNewService::new(self, f)
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ impl<A, F, Response> Map<A, F, Response> {
|
|||||||
pub fn new<Request>(service: A, f: F) -> Self
|
pub fn new<Request>(service: A, f: F) -> Self
|
||||||
where
|
where
|
||||||
A: Service<Request>,
|
A: Service<Request>,
|
||||||
F: Fn(A::Response) -> Response,
|
F: FnMut(A::Response) -> Response,
|
||||||
{
|
{
|
||||||
Self {
|
Self {
|
||||||
service,
|
service,
|
||||||
@ -45,7 +45,7 @@ where
|
|||||||
impl<A, F, Request, Response> Service<Request> for Map<A, F, Response>
|
impl<A, F, Request, Response> Service<Request> for Map<A, F, Response>
|
||||||
where
|
where
|
||||||
A: Service<Request>,
|
A: Service<Request>,
|
||||||
F: Fn(A::Response) -> Response + Clone,
|
F: FnMut(A::Response) -> Response + Clone,
|
||||||
{
|
{
|
||||||
type Response = Response;
|
type Response = Response;
|
||||||
type Error = A::Error;
|
type Error = A::Error;
|
||||||
@ -63,7 +63,7 @@ where
|
|||||||
pub struct MapFuture<A, F, Request, Response>
|
pub struct MapFuture<A, F, Request, Response>
|
||||||
where
|
where
|
||||||
A: Service<Request>,
|
A: Service<Request>,
|
||||||
F: Fn(A::Response) -> Response,
|
F: FnMut(A::Response) -> Response,
|
||||||
{
|
{
|
||||||
f: F,
|
f: F,
|
||||||
fut: A::Future,
|
fut: A::Future,
|
||||||
@ -72,7 +72,7 @@ where
|
|||||||
impl<A, F, Request, Response> MapFuture<A, F, Request, Response>
|
impl<A, F, Request, Response> MapFuture<A, F, Request, Response>
|
||||||
where
|
where
|
||||||
A: Service<Request>,
|
A: Service<Request>,
|
||||||
F: Fn(A::Response) -> Response,
|
F: FnMut(A::Response) -> Response,
|
||||||
{
|
{
|
||||||
fn new(fut: A::Future, f: F) -> Self {
|
fn new(fut: A::Future, f: F) -> Self {
|
||||||
MapFuture { f, fut }
|
MapFuture { f, fut }
|
||||||
@ -82,7 +82,7 @@ where
|
|||||||
impl<A, F, Request, Response> Future for MapFuture<A, F, Request, Response>
|
impl<A, F, Request, Response> Future for MapFuture<A, F, Request, Response>
|
||||||
where
|
where
|
||||||
A: Service<Request>,
|
A: Service<Request>,
|
||||||
F: Fn(A::Response) -> Response,
|
F: FnMut(A::Response) -> Response,
|
||||||
{
|
{
|
||||||
type Item = Response;
|
type Item = Response;
|
||||||
type Error = A::Error;
|
type Error = A::Error;
|
||||||
@ -107,7 +107,7 @@ impl<A, F, Response> MapNewService<A, F, Response> {
|
|||||||
pub fn new<Request>(a: A, f: F) -> Self
|
pub fn new<Request>(a: A, f: F) -> Self
|
||||||
where
|
where
|
||||||
A: NewService<Request>,
|
A: NewService<Request>,
|
||||||
F: Fn(A::Response) -> Response,
|
F: FnMut(A::Response) -> Response,
|
||||||
{
|
{
|
||||||
Self {
|
Self {
|
||||||
a,
|
a,
|
||||||
@ -134,7 +134,7 @@ where
|
|||||||
impl<A, F, Request, Response> NewService<Request> for MapNewService<A, F, Response>
|
impl<A, F, Request, Response> NewService<Request> for MapNewService<A, F, Response>
|
||||||
where
|
where
|
||||||
A: NewService<Request>,
|
A: NewService<Request>,
|
||||||
F: Fn(A::Response) -> Response + Clone,
|
F: FnMut(A::Response) -> Response + Clone,
|
||||||
{
|
{
|
||||||
type Response = Response;
|
type Response = Response;
|
||||||
type Error = A::Error;
|
type Error = A::Error;
|
||||||
@ -151,7 +151,7 @@ where
|
|||||||
pub struct MapNewServiceFuture<A, F, Request, Response>
|
pub struct MapNewServiceFuture<A, F, Request, Response>
|
||||||
where
|
where
|
||||||
A: NewService<Request>,
|
A: NewService<Request>,
|
||||||
F: Fn(A::Response) -> Response,
|
F: FnMut(A::Response) -> Response,
|
||||||
{
|
{
|
||||||
fut: A::Future,
|
fut: A::Future,
|
||||||
f: Option<F>,
|
f: Option<F>,
|
||||||
@ -160,7 +160,7 @@ where
|
|||||||
impl<A, F, Request, Response> MapNewServiceFuture<A, F, Request, Response>
|
impl<A, F, Request, Response> MapNewServiceFuture<A, F, Request, Response>
|
||||||
where
|
where
|
||||||
A: NewService<Request>,
|
A: NewService<Request>,
|
||||||
F: Fn(A::Response) -> Response,
|
F: FnMut(A::Response) -> Response,
|
||||||
{
|
{
|
||||||
fn new(fut: A::Future, f: F) -> Self {
|
fn new(fut: A::Future, f: F) -> Self {
|
||||||
MapNewServiceFuture { f: Some(f), fut }
|
MapNewServiceFuture { f: Some(f), fut }
|
||||||
@ -170,7 +170,7 @@ where
|
|||||||
impl<A, F, Request, Response> Future for MapNewServiceFuture<A, F, Request, Response>
|
impl<A, F, Request, Response> Future for MapNewServiceFuture<A, F, Request, Response>
|
||||||
where
|
where
|
||||||
A: NewService<Request>,
|
A: NewService<Request>,
|
||||||
F: Fn(A::Response) -> Response,
|
F: FnMut(A::Response) -> Response,
|
||||||
{
|
{
|
||||||
type Item = Map<A::Service, F, Response>;
|
type Item = Map<A::Service, F, Response>;
|
||||||
type Error = A::InitError;
|
type Error = A::InitError;
|
||||||
|
Loading…
Reference in New Issue
Block a user