From b599bc4a0caff190f257125f876b00391d9a1a14 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Sun, 22 Dec 2019 16:30:49 +0400 Subject: [PATCH] map_config() and unit_config() accepts IntoServiceFactory type --- actix-service/CHANGES.md | 7 +++++++ actix-service/Cargo.toml | 2 +- actix-service/src/map_config.rs | 14 ++++++++------ 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/actix-service/CHANGES.md b/actix-service/CHANGES.md index 1dad989e..4aa8a31b 100644 --- a/actix-service/CHANGES.md +++ b/actix-service/CHANGES.md @@ -1,5 +1,12 @@ # Changes +## [1.0.1] - 2019-12-22 + +### Changed + +* `map_config()` and `unit_config()` accepts `IntoServiceFactory` type + + ## [1.0.0] - 2019-12-11 ### Added diff --git a/actix-service/Cargo.toml b/actix-service/Cargo.toml index 31926c58..cd6507fa 100644 --- a/actix-service/Cargo.toml +++ b/actix-service/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-service" -version = "1.0.0" +version = "1.0.1" authors = ["Nikolay Kim "] description = "Actix service" keywords = ["network", "framework", "async", "futures"] diff --git a/actix-service/src/map_config.rs b/actix-service/src/map_config.rs index 40b27c7d..7a1a1b89 100644 --- a/actix-service/src/map_config.rs +++ b/actix-service/src/map_config.rs @@ -1,28 +1,30 @@ use std::marker::PhantomData; -use super::ServiceFactory; +use super::{IntoServiceFactory, ServiceFactory}; /// Adapt external config argument to a config for provided service factory /// /// Note that this function consumes the receiving service factory and returns /// a wrapped version of it. -pub fn map_config(factory: T, f: F) -> MapConfig +pub fn map_config(factory: U, f: F) -> MapConfig where T: ServiceFactory, + U: IntoServiceFactory, F: Fn(C) -> T::Config, { - MapConfig::new(factory, f) + MapConfig::new(factory.into_factory(), f) } /// Replace config with unit -pub fn unit_config(new_service: T) -> UnitConfig +pub fn unit_config(factory: U) -> UnitConfig where T: ServiceFactory, + U: IntoServiceFactory, { - UnitConfig::new(new_service) + UnitConfig::new(factory.into_factory()) } -/// `.map_config()` service combinator +/// `map_config()` adapter service factory pub struct MapConfig { a: A, f: F,