#![warn(rust_2018_idioms)] use futures_util::future; use futures_util::future::FutureExt; use std::env; use std::future::Future; use std::time::Duration; use tokio::timer::Timeout; use tokio_process::Command; #[allow(dead_code)] pub fn cmd(s: &str) -> Command { let mut me = env::current_exe().unwrap(); me.pop(); if me.ends_with("deps") { me.pop(); } me.push(s); Command::new(me) } pub fn with_timeout(future: F) -> impl Future { Timeout::new(future, Duration::from_secs(3)).then(|r| { if r.is_err() { panic!("timed out {:?}", r.err()); } future::ready(r.unwrap()) }) }