Skip to content

Commit

Permalink
chore(core): short form
Browse files Browse the repository at this point in the history
  • Loading branch information
fundon committed Dec 30, 2023
1 parent f49a64c commit e790e33
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 36 deletions.
3 changes: 1 addition & 2 deletions viz-core/src/handler/after.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ where

fn call(&self, i: I) -> BoxFuture<Self::Output> {
let f = self.f.clone();
let fut = self.h.call(i).then(move |o| f.call(o));
Box::pin(fut)
Box::pin(self.h.call(i).then(move |o| f.call(o)))
}
}
3 changes: 1 addition & 2 deletions viz-core/src/handler/and_then.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ where

fn call(&self, i: I) -> BoxFuture<Self::Output> {
let f = self.f.clone();
let fut = self.h.call(i).and_then(move |o| f.call(o));
Box::pin(fut)
Box::pin(self.h.call(i).and_then(move |o| f.call(o)))
}
}
3 changes: 1 addition & 2 deletions viz-core/src/handler/around.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ where
type Output = F::Output;

fn call(&self, i: I) -> BoxFuture<Self::Output> {
let h = self.h.clone();
Box::pin(self.f.call((i, h)))
Box::pin(self.f.call((i, self.h.clone())))
}
}
3 changes: 1 addition & 2 deletions viz-core/src/handler/before.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ where

fn call(&self, i: I) -> BoxFuture<Self::Output> {
let h = self.h.clone();
let fut = self.f.call(i).and_then(move |i| h.call(i));
Box::pin(fut)
Box::pin(self.f.call(i).and_then(move |i| h.call(i)))
}
}
14 changes: 7 additions & 7 deletions viz-core/src/handler/catch_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ where

fn call(&self, i: I) -> BoxFuture<Self::Output> {
let f = self.f.clone();
let fut = self
.h
.call(i)
.map_ok(IntoResponse::into_response)
.map_err(Error::downcast::<E>)
.or_else(move |r| async move { Ok(f.call(r?).await.into_response()) });
Box::pin(fut)
Box::pin(
self.h
.call(i)
.map_ok(IntoResponse::into_response)
.map_err(Error::downcast::<E>)
.or_else(move |r| async move { Ok(f.call(r?).await.into_response()) }),
)
}
}
11 changes: 6 additions & 5 deletions viz-core/src/handler/catch_unwind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ where

fn call(&self, i: I) -> BoxFuture<Self::Output> {
let f = self.f.clone();
let fut = ::core::panic::AssertUnwindSafe(self.h.call(i))
.catch_unwind()
.map_ok(IntoResponse::into_response)
.or_else(move |e| f.call(e).map(IntoResponse::into_response).map(Result::Ok));
Box::pin(fut)
Box::pin(
::core::panic::AssertUnwindSafe(self.h.call(i))
.catch_unwind()
.map_ok(IntoResponse::into_response)
.or_else(move |e| f.call(e).map(IntoResponse::into_response).map(Result::Ok)),
)
}
}
3 changes: 1 addition & 2 deletions viz-core/src/handler/fn_ext_hanlder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ where
type Output = H::Output;

fn call(&self, req: Request) -> BoxFuture<Self::Output> {
let fut = self.0.call(req).map_err(IntoResponse::into_error);
Box::pin(fut)
Box::pin(self.0.call(req).map_err(IntoResponse::into_error))
}
}
3 changes: 1 addition & 2 deletions viz-core/src/handler/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ where
type Output = Result<T>;

fn call(&self, i: I) -> BoxFuture<Self::Output> {
let fut = self.h.call(i).map_ok(self.f.clone());
Box::pin(fut)
Box::pin(self.h.call(i).map_ok(self.f.clone()))
}
}
3 changes: 1 addition & 2 deletions viz-core/src/handler/map_err.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ where
type Output = Result<O>;

fn call(&self, i: I) -> BoxFuture<Self::Output> {
let fut = self.h.call(i).map_err(self.f.clone());
Box::pin(fut)
Box::pin(self.h.call(i).map_err(self.f.clone()))
}
}
3 changes: 1 addition & 2 deletions viz-core/src/handler/map_into_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ where
type Output = Result<Response>;

fn call(&self, i: I) -> BoxFuture<Self::Output> {
let fut = self.0.call(i).map_ok(IntoResponse::into_response);
Box::pin(fut)
Box::pin(self.0.call(i).map_ok(IntoResponse::into_response))
}
}
3 changes: 1 addition & 2 deletions viz-core/src/handler/or_else.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ where

fn call(&self, i: I) -> BoxFuture<Self::Output> {
let f = self.f.clone();
let fut = self.h.call(i).or_else(move |e| f.call(e));
Box::pin(fut)
Box::pin(self.h.call(i).or_else(move |e| f.call(e)))
}
}
12 changes: 6 additions & 6 deletions viz-core/src/handler/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ where
type Output = Result<Response>;

fn call(&self, req: Request<I>) -> BoxFuture<Self::Output> {
let fut = self
.0
.call(req)
.map_ok(|resp| resp.map(Body::wrap))
.map_err(Error::boxed);
Box::pin(fut)
Box::pin(
self.0
.call(req)
.map_ok(|resp| resp.map(Body::wrap))
.map_err(Error::boxed),
)
}
}

0 comments on commit e790e33

Please sign in to comment.