orphanage 0.5.6

Random collection of stuff that is still searching for a home.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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 :