1
0
mirror of https://github.com/fafhrd91/actix-net synced 2025-01-31 08:12:07 +01:00

fix map_err constraints

This commit is contained in:
Nikolay Kim 2019-03-12 13:45:05 -07:00
parent 755d4958c5
commit e7465bfa2e
2 changed files with 14 additions and 10 deletions

View File

@ -335,7 +335,7 @@ pub trait NewService<Config = ()> {
fn map_err<F, E>(self, f: F) -> MapErrNewService<Self, F, E, Config>
where
Self: Sized,
F: Fn(Self::Error) -> E,
F: Fn(Self::Error) -> E + Clone,
{
MapErrNewService::new(self, f)
}

View File

@ -98,19 +98,23 @@ where
/// service's error.
///
/// This is created by the `NewServiceExt::map_err` method.
pub struct MapErrNewService<A, F, E, C> {
pub struct MapErrNewService<A, F, E, C>
where
A: NewService<C>,
F: Fn(A::Error) -> E + Clone,
{
a: A,
f: F,
e: PhantomData<(E, C)>,
}
impl<A, F, E, C> MapErrNewService<A, F, E, C> {
impl<A, F, E, C> MapErrNewService<A, F, E, C>
where
A: NewService<C>,
F: Fn(A::Error) -> E + Clone,
{
/// Create new `MapErr` new service instance
pub fn new(a: A, f: F) -> Self
where
A: NewService<C>,
F: Fn(A::Error) -> E,
{
pub fn new(a: A, f: F) -> Self {
Self {
a,
f,
@ -121,8 +125,8 @@ impl<A, F, E, C> MapErrNewService<A, F, E, C> {
impl<A, F, E, C> Clone for MapErrNewService<A, F, E, C>
where
A: Clone,
F: Clone,
A: NewService<C> + Clone,
F: Fn(A::Error) -> E + Clone,
{
fn clone(&self) -> Self {
Self {