Macro microbit::try_nb

source ·
macro_rules! try_nb {
    ($e:expr) => { ... };
}
Expand description

Future adapter

This is a try operation from a nb::Result to a futures::Poll

Requirements

This macro must be called within a function / closure that has signature fn(..) -> futures::Poll<T, E>.

This macro requires that the futures crate is in the root of the crate.

Input

An expression $e that evaluates to nb::Result<T, E>

Early return

  • Ok(Async::NotReady) if $e evaluates to Err(nb::Error::WouldBlock)
  • Err(e) if $e evaluates to Err(nb::Error::Other(e))

Output

t if $e evaluates to Ok(t)