mirror of
https://github.com/fafhrd91/actix-net
synced 2024-11-30 17:44:34 +01:00
change Either constructor
This commit is contained in:
parent
837504c10f
commit
0a6cded975
@ -33,7 +33,7 @@ pub trait TowerServiceExt {
|
||||
impl<S> TowerServiceExt for S {
|
||||
fn compat<R>(self) -> TowerCompat<Self, R>
|
||||
where
|
||||
Self: TowerService<R> + Sized
|
||||
Self: TowerService<R> + 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,7 +182,10 @@ 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());
|
||||
|
||||
|
@ -1,5 +1,12 @@
|
||||
# Changes
|
||||
|
||||
##[0.4.1] - 2019-05-xx
|
||||
|
||||
### Changed
|
||||
|
||||
* Change `Either` constructor
|
||||
|
||||
|
||||
## [0.4.0] - 2019-05-11
|
||||
|
||||
### Changed
|
||||
|
@ -57,25 +57,21 @@ pub struct Either<A, B> {
|
||||
}
|
||||
|
||||
impl<A, B> Either<A, B> {
|
||||
pub fn new_a<F>(srv: F) -> Either<A, ()>
|
||||
pub fn new<F1, F2>(srv_a: F1, srv_b: F2) -> Either<A, B>
|
||||
where
|
||||
A: NewService,
|
||||
F: IntoNewService<A>,
|
||||
B: NewService<
|
||||
Config = A::Config,
|
||||
Response = A::Response,
|
||||
Error = A::Error,
|
||||
InitError = A::InitError,
|
||||
>,
|
||||
F1: IntoNewService<A>,
|
||||
F2: IntoNewService<B>,
|
||||
{
|
||||
Either {
|
||||
left: srv.into_new_service(),
|
||||
right: (),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_b<F>(srv: F) -> Either<(), B>
|
||||
where
|
||||
B: NewService,
|
||||
F: IntoNewService<B>,
|
||||
{
|
||||
Either {
|
||||
left: (),
|
||||
right: srv.into_new_service(),
|
||||
left: srv_a.into_new_service(),
|
||||
right: srv_b.into_new_service(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user