From 0a6cded9753c938b95e6128350f608914d4946e1 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Tue, 14 May 2019 17:32:50 -0700 Subject: [PATCH] change Either constructor --- actix-tower/src/lib.rs | 11 +++++++---- actix-utils/CHANGES.md | 7 +++++++ actix-utils/src/either.rs | 26 +++++++++++--------------- 3 files changed, 25 insertions(+), 19 deletions(-) diff --git a/actix-tower/src/lib.rs b/actix-tower/src/lib.rs index 1e985db2..30b01ce2 100644 --- a/actix-tower/src/lib.rs +++ b/actix-tower/src/lib.rs @@ -33,7 +33,7 @@ pub trait TowerServiceExt { impl TowerServiceExt for S { fn compat(self) -> TowerCompat where - Self: TowerService + Sized + Self: TowerService + Sized, { TowerCompat::new(self) } @@ -61,7 +61,7 @@ where mod tests { use super::TowerServiceExt; use actix_service::{Service as ActixService, ServiceExt, Transform}; - use futures::{future::FutureResult, Async, Poll, Future}; + use futures::{future::FutureResult, Async, Future, Poll}; use tower_service::Service as TowerService; struct RandomService; @@ -182,10 +182,13 @@ mod tests { fn tower_service_as_actix_service_can_be_transformed() { let transform = DoMath; - let mut s = transform.new_transform(RandomService.compat()).wait().unwrap(); + let mut s = transform + .new_transform(RandomService.compat()) + .wait() + .unwrap(); assert_eq!(Ok(Async::Ready(())), s.poll_ready()); assert_eq!(Ok(Async::Ready(68)), s.call(()).poll()); } -} \ No newline at end of file +} diff --git a/actix-utils/CHANGES.md b/actix-utils/CHANGES.md index a794c1e4..2e418e39 100644 --- a/actix-utils/CHANGES.md +++ b/actix-utils/CHANGES.md @@ -1,5 +1,12 @@ # Changes +##[0.4.1] - 2019-05-xx + +### Changed + +* Change `Either` constructor + + ## [0.4.0] - 2019-05-11 ### Changed diff --git a/actix-utils/src/either.rs b/actix-utils/src/either.rs index 9078ae24..6bd4e59e 100644 --- a/actix-utils/src/either.rs +++ b/actix-utils/src/either.rs @@ -57,25 +57,21 @@ pub struct Either { } impl Either { - pub fn new_a(srv: F) -> Either + pub fn new(srv_a: F1, srv_b: F2) -> Either where A: NewService, - F: IntoNewService, + B: NewService< + Config = A::Config, + Response = A::Response, + Error = A::Error, + InitError = A::InitError, + >, + F1: IntoNewService, + F2: IntoNewService, { Either { - left: srv.into_new_service(), - right: (), - } - } - - pub fn new_b(srv: F) -> Either<(), B> - where - B: NewService, - F: IntoNewService, - { - Either { - left: (), - right: srv.into_new_service(), + left: srv_a.into_new_service(), + right: srv_b.into_new_service(), } } }