From 2c8e7c4ae439bcc74b2aec4197d50c10ec1ca9cf Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Wed, 16 Jan 2019 15:33:10 -0800 Subject: [PATCH] add helper constructors to Either service --- actix-utils/src/either.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/actix-utils/src/either.rs b/actix-utils/src/either.rs index 54495005..272b1213 100644 --- a/actix-utils/src/either.rs +++ b/actix-utils/src/either.rs @@ -51,6 +51,34 @@ pub enum Either { B(B), } +impl Either { + pub fn new_a(srv: A) -> Self + where + A: NewService, + B: NewService< + Request, + Response = A::Response, + Error = A::Error, + InitError = A::InitError, + >, + { + Either::A(srv) + } + + pub fn new_b(srv: B) -> Self + where + A: NewService, + B: NewService< + Request, + Response = A::Response, + Error = A::Error, + InitError = A::InitError, + >, + { + Either::B(srv) + } +} + impl NewService for Either where A: NewService,