refactor(service): change service_fn to take Fn instead of FnMut

This commit is contained in:
Sean McArthur
2018-05-02 13:46:33 -07:00
parent 190a8501d6
commit 283d79db08
2 changed files with 5 additions and 5 deletions

View File

@@ -5,7 +5,7 @@
//!
//! There are two levels of APIs provide for constructing HTTP servers:
//!
//! - The higher-level [`Server`](Server).
//! - The higher-level [`Server`](Server) type.
//! - The lower-level [conn](conn) module.
//!
//! # Server

View File

@@ -51,7 +51,7 @@ pub trait Service {
/// ```
pub fn service_fn<F, R, S>(f: F) -> ServiceFn<F, R>
where
F: FnMut(Request<R>) -> S,
F: Fn(Request<R>) -> S,
S: IntoFuture,
{
ServiceFn {
@@ -75,7 +75,7 @@ where
/// ```
pub fn service_fn_ok<F, R, S>(f: F) -> ServiceFnOk<F, R>
where
F: FnMut(Request<R>) -> Response<S>,
F: Fn(Request<R>) -> Response<S>,
S: Payload,
{
ServiceFnOk {
@@ -92,7 +92,7 @@ pub struct ServiceFn<F, R> {
impl<F, ReqBody, Ret, ResBody> Service for ServiceFn<F, ReqBody>
where
F: FnMut(Request<ReqBody>) -> Ret,
F: Fn(Request<ReqBody>) -> Ret,
ReqBody: Payload,
Ret: IntoFuture<Item=Response<ResBody>>,
Ret::Error: Into<Box<StdError + Send + Sync>>,
@@ -133,7 +133,7 @@ pub struct ServiceFnOk<F, R> {
impl<F, ReqBody, ResBody> Service for ServiceFnOk<F, ReqBody>
where
F: FnMut(Request<ReqBody>) -> Response<ResBody>,
F: Fn(Request<ReqBody>) -> Response<ResBody>,
ReqBody: Payload,
ResBody: Payload,
{