summaryrefslogtreecommitdiff
path: root/cli/worker.rs
diff options
context:
space:
mode:
authorGurwinder Singh <vargwin@gmail.com>2020-01-01 20:21:27 +0530
committerRy Dahl <ry@tinyclouds.org>2020-01-01 09:51:27 -0500
commit55add2d366c5b3e19bd91958f3e3a36b4439839d (patch)
tree35c68bbc6140ea99c9deebe12c0fb1abc85ae2e8 /cli/worker.rs
parent4258ed262f6eed9b0ee123e1ba9c91f999f0b429 (diff)
cleanup after tokio upgrade (#3571)
tokio_util::run and tokio::run_on_current_thread should accept Future<Output=()> instead of Future<Output=Result<(), ()>>. Currently, all the passed futures have to add Ok(()) or futures::future::ok(()) unnecessarily to call this method.
Diffstat (limited to 'cli/worker.rs')
-rw-r--r--cli/worker.rs13
1 files changed, 6 insertions, 7 deletions
diff --git a/cli/worker.rs b/cli/worker.rs
index c44dfbb39..2e995ebe6 100644
--- a/cli/worker.rs
+++ b/cli/worker.rs
@@ -222,20 +222,19 @@ mod tests {
where
F: FnOnce() + Send + 'static,
{
- let fut = futures::future::lazy(move |_cx| {
- f();
- Ok(())
- });
-
+ let fut = futures::future::lazy(move |_cx| f());
tokio_util::run(fut)
}
- pub fn panic_on_error<I, E, F>(f: F) -> impl Future<Output = Result<I, ()>>
+ pub async fn panic_on_error<I, E, F>(f: F) -> I
where
F: Future<Output = Result<I, E>>,
E: std::fmt::Debug,
{
- f.map_err(|err| panic!("Future got unexpected error: {:?}", err))
+ match f.await {
+ Ok(v) => v,
+ Err(e) => panic!("Future got unexpected error: {:?}", e),
+ }
}
#[test]