From 3d7daabdd7d69feba6bb2abb2d20075f29210784 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Tue, 19 Feb 2019 11:31:54 -0800 Subject: [PATCH] add NewService impls for Rc and Arc --- actix-service/CHANGES.md | 9 +++++++++ actix-service/Cargo.toml | 2 +- actix-service/src/lib.rs | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) diff --git a/actix-service/CHANGES.md b/actix-service/CHANGES.md index 796f54e6..7c2e4a69 100644 --- a/actix-service/CHANGES.md +++ b/actix-service/CHANGES.md @@ -1,5 +1,14 @@ # Changes +## [0.2.2] - 2019-02-19 + +### Added + +* Added `NewService` impl for `Rc where S: NewService` + +* Added `NewService` impl for `Arc where S: NewService` + + ## [0.2.1] - 2019-02-03 ### Changed diff --git a/actix-service/Cargo.toml b/actix-service/Cargo.toml index 7ea60982..5a06e33a 100644 --- a/actix-service/Cargo.toml +++ b/actix-service/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-service" -version = "0.2.1" +version = "0.2.2" authors = ["Nikolay Kim "] description = "Actix Service" keywords = ["network", "framework", "async", "futures"] diff --git a/actix-service/src/lib.rs b/actix-service/src/lib.rs index fb2186b0..a960782e 100644 --- a/actix-service/src/lib.rs +++ b/actix-service/src/lib.rs @@ -1,3 +1,6 @@ +use std::rc::Rc; +use std::sync::Arc; + use futures::{Future, IntoFuture, Poll}; mod and_then; @@ -377,6 +380,38 @@ where } } +impl NewService for Rc +where + S: NewService, +{ + type Request = S::Request; + type Response = S::Response; + type Error = S::Error; + type Service = S::Service; + type InitError = S::InitError; + type Future = S::Future; + + fn new_service(&self) -> S::Future { + self.as_ref().new_service() + } +} + +impl NewService for Arc +where + S: NewService, +{ + type Request = S::Request; + type Response = S::Response; + type Error = S::Error; + type Service = S::Service; + type InitError = S::InitError; + type Future = S::Future; + + fn new_service(&self) -> S::Future { + self.as_ref().new_service() + } +} + /// Trait for types that can be converted to a `Service` pub trait IntoService where