1
0
mirror of https://github.com/fafhrd91/actix-net synced 2024-11-30 16:34:36 +01:00

Use FnMut instead of Fn for FnService

This commit is contained in:
Nikolay Kim 2019-01-11 21:39:58 -08:00
parent b5d84bd980
commit 316974616a
3 changed files with 18 additions and 11 deletions

View File

@ -1,5 +1,12 @@
# Changes # Changes
## [0.1.4] - 2019-01-11
## Changed
* Use `FnMut` instead of `Fn` for `FnService`
## [0.1.3] - 2018-12-12 ## [0.1.3] - 2018-12-12
## Changed ## Changed

View File

@ -1,6 +1,6 @@
[package] [package]
name = "actix-service" name = "actix-service"
version = "0.1.3" version = "0.1.4"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"] authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
description = "Actix Service" description = "Actix Service"
keywords = ["network", "framework", "async", "futures"] keywords = ["network", "framework", "async", "futures"]

View File

@ -9,7 +9,7 @@ use super::{IntoNewService, IntoService, NewService, Service};
pub struct FnService<F, Req, Resp, E, Fut> pub struct FnService<F, Req, Resp, E, Fut>
where where
F: Fn(Req) -> Fut, F: FnMut(Req) -> Fut,
Fut: IntoFuture<Item = Resp, Error = E>, Fut: IntoFuture<Item = Resp, Error = E>,
{ {
f: F, f: F,
@ -18,7 +18,7 @@ where
impl<F, Req, Resp, E, Fut> FnService<F, Req, Resp, E, Fut> impl<F, Req, Resp, E, Fut> FnService<F, Req, Resp, E, Fut>
where where
F: Fn(Req) -> Fut, F: FnMut(Req) -> Fut,
Fut: IntoFuture<Item = Resp, Error = E>, Fut: IntoFuture<Item = Resp, Error = E>,
{ {
pub fn new(f: F) -> Self { pub fn new(f: F) -> Self {
@ -31,7 +31,7 @@ where
impl<F, Req, Resp, E, Fut> Clone for FnService<F, Req, Resp, E, Fut> impl<F, Req, Resp, E, Fut> Clone for FnService<F, Req, Resp, E, Fut>
where where
F: Fn(Req) -> Fut + Clone, F: FnMut(Req) -> Fut + Clone,
Fut: IntoFuture<Item = Resp, Error = E>, Fut: IntoFuture<Item = Resp, Error = E>,
{ {
fn clone(&self) -> Self { fn clone(&self) -> Self {
@ -44,7 +44,7 @@ where
impl<F, Req, Resp, E, Fut> Service<Req> for FnService<F, Req, Resp, E, Fut> impl<F, Req, Resp, E, Fut> Service<Req> for FnService<F, Req, Resp, E, Fut>
where where
F: Fn(Req) -> Fut, F: FnMut(Req) -> Fut,
Fut: IntoFuture<Item = Resp, Error = E>, Fut: IntoFuture<Item = Resp, Error = E>,
{ {
type Response = Resp; type Response = Resp;
@ -62,7 +62,7 @@ where
impl<F, Req, Resp, Err, Fut> IntoService<FnService<F, Req, Resp, Err, Fut>, Req> for F impl<F, Req, Resp, Err, Fut> IntoService<FnService<F, Req, Resp, Err, Fut>, Req> for F
where where
F: Fn(Req) -> Fut + 'static, F: FnMut(Req) -> Fut + 'static,
Fut: IntoFuture<Item = Resp, Error = Err>, Fut: IntoFuture<Item = Resp, Error = Err>,
{ {
fn into_service(self) -> FnService<F, Req, Resp, Err, Fut> { fn into_service(self) -> FnService<F, Req, Resp, Err, Fut> {
@ -72,7 +72,7 @@ where
pub struct FnNewService<F, Req, Resp, Err, Fut> pub struct FnNewService<F, Req, Resp, Err, Fut>
where where
F: Fn(Req) -> Fut, F: FnMut(Req) -> Fut,
Fut: IntoFuture<Item = Resp, Error = Err>, Fut: IntoFuture<Item = Resp, Error = Err>,
{ {
f: F, f: F,
@ -81,7 +81,7 @@ where
impl<F, Req, Resp, Err, Fut> FnNewService<F, Req, Resp, Err, Fut> impl<F, Req, Resp, Err, Fut> FnNewService<F, Req, Resp, Err, Fut>
where where
F: Fn(Req) -> Fut + Clone, F: FnMut(Req) -> Fut + Clone,
Fut: IntoFuture<Item = Resp, Error = Err>, Fut: IntoFuture<Item = Resp, Error = Err>,
{ {
pub fn new(f: F) -> Self { pub fn new(f: F) -> Self {
@ -94,7 +94,7 @@ where
impl<F, Req, Resp, Err, Fut> NewService<Req> for FnNewService<F, Req, Resp, Err, Fut> impl<F, Req, Resp, Err, Fut> NewService<Req> for FnNewService<F, Req, Resp, Err, Fut>
where where
F: Fn(Req) -> Fut + Clone, F: FnMut(Req) -> Fut + Clone,
Fut: IntoFuture<Item = Resp, Error = Err>, Fut: IntoFuture<Item = Resp, Error = Err>,
{ {
type Response = Resp; type Response = Resp;
@ -110,7 +110,7 @@ where
impl<F, Req, Resp, Err, Fut> IntoNewService<FnNewService<F, Req, Resp, Err, Fut>, Req> for F impl<F, Req, Resp, Err, Fut> IntoNewService<FnNewService<F, Req, Resp, Err, Fut>, Req> for F
where where
F: Fn(Req) -> Fut + Clone + 'static, F: FnMut(Req) -> Fut + Clone + 'static,
Fut: IntoFuture<Item = Resp, Error = Err>, Fut: IntoFuture<Item = Resp, Error = Err>,
{ {
fn into_new_service(self) -> FnNewService<F, Req, Resp, Err, Fut> { fn into_new_service(self) -> FnNewService<F, Req, Resp, Err, Fut> {
@ -120,7 +120,7 @@ where
impl<F, Req, Resp, Err, Fut> Clone for FnNewService<F, Req, Resp, Err, Fut> impl<F, Req, Resp, Err, Fut> Clone for FnNewService<F, Req, Resp, Err, Fut>
where where
F: Fn(Req) -> Fut + Clone, F: FnMut(Req) -> Fut + Clone,
Fut: IntoFuture<Item = Resp, Error = Err>, Fut: IntoFuture<Item = Resp, Error = Err>,
{ {
fn clone(&self) -> Self { fn clone(&self) -> Self {