use std::future::Future;
/// If `f` is `Some`, then `await` its inner value. Otherwise return
/// `Pending`.
pub async fn if_some<F>(f: &mut Option<F>) -> Option<F::Output>
where
F: Future + Unpin + Send
{
match f.as_mut() {
Some(fut) => Some(fut.await),
None => std::future::pending().await
}
}
// vim: set ft=rust et sw=2 ts=2 sts=2 cinoptions=2 tw=79 :